arbeiten an unitTests

Abhängigkeit macht Probleme
This commit is contained in:
chk
2026-05-25 08:43:07 +02:00
parent 1534170b7f
commit 99794b944d
12 changed files with 216 additions and 130 deletions

View File

@@ -1,32 +1,52 @@
const { execSync } = require('child_process');
const fs = require('fs');
const os = require('os');
const path = require('path');
const BASE_PATH = path.join(__dirname, '..');
const PYTHON_CMD = process.platform === 'win32' ? 'python' : 'python3';
const screenshotFiles = [
'snapshot_video0_1778819665744.jpg',
'snapshot_video1_1778819665744.jpg',
];
let tempDir;
describe('Camera Pose Script', () => {
beforeEach(() => {
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'AA_readTwoImages-'));
const sourceDir = path.join(__dirname, 'data', 'screenShots');
test('should build scene JSON with timestamp parameter', () => {
screenshotFiles.forEach((file) => {
const src = path.join(sourceDir, file);
const dst = path.join(tempDir, file);
if (!fs.existsSync(src)) {
throw new Error(`Missing test fixture screenshot: ${src}`);
}
fs.copyFileSync(src, dst);
});
});
const outDir = "test/data/screenShots";
const strFile0 = path.join(outDir, "snapshot_video0_1778819665744.jpg");
const strFile1 = path.join(outDir, "snapshot_video1_1778819665744.jpg");
afterEach(() => {
if (tempDir && fs.existsSync(tempDir)) {
fs.rmSync(tempDir, { recursive: true, force: true });
}
});
const command2 = `${PYTHON_CMD} ${path.join(BASE_PATH, 'programs/readTwoImages.py')} \
-i ${strFile0} \
-i ${strFile1} \
-npz ${path.join(BASE_PATH, 'data/settings/callibration_cam0.npz')} \
-npz ${path.join(BASE_PATH, 'data/settings/callibration_cam1.npz')} \
-settings ${path.join(BASE_PATH, 'data/settings/settings1m.json')}`;
test('should execute readTwoImages without modifying shared fixtures', () => {
const strFile0 = path.join(tempDir, 'snapshot_video0_1778819665744.jpg');
const strFile1 = path.join(tempDir, 'snapshot_video1_1778819665744.jpg');
const command2 = `${PYTHON_CMD} "${path.join(BASE_PATH, 'programs/readTwoImages.py')}" \
-i "${strFile0}" \
-i "${strFile1}" \
-npz "${path.join(BASE_PATH, 'data/settings/callibration_cam0.npz')}" \
-npz "${path.join(BASE_PATH, 'data/settings/callibration_cam1.npz')}" \
-settings "${path.join(BASE_PATH, 'data/settings/settings1m.json')}"`;
try {
execSync(command2, { stdio: 'inherit' });
} catch (error) {
fail(`Failed to execute command: ${error.message}`);
}
});
try {
execSync(command2, { stdio: 'inherit' });
} catch (error) {
fail(`Failed to execute command: ${error.message}`);
}
});
});