9月20日
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { mkdtempSync, readdirSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join, dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const output = mkdtempSync(join(tmpdir(), 'receipt-ui-checks-'));
|
||||
console.log(`Validation output: ${output}`);
|
||||
const domain = ['Models', 'MatchExplanation'];
|
||||
const cases = {
|
||||
PairConnectionLayout: ['PairConnectionLayout'],
|
||||
WorkspacePresentation: [...domain, 'WorkspacePresentation', 'MatchedPPTSelection'],
|
||||
TemplateMappingValidation: ['ExpenseTemplate', 'TemplateMappingValidation'],
|
||||
MatchedPPTSelection: [...domain, 'MatchedPPTSelection'],
|
||||
ExpenseSummary: [...domain, 'MatchedPPTSelection', 'ExpenseSummary'],
|
||||
MatchExplanation: domain,
|
||||
ExpenseTemplate: ['ExpenseTemplate'],
|
||||
ExpensePreview: ['ExpenseTemplate', 'ExpensePreview', 'SpreadsheetLayout'],
|
||||
FolderImportSource: ['FolderImportSource'],
|
||||
PayeeProfile: ['PayeeProfile'],
|
||||
AdminAttachments: ['AdminModels'],
|
||||
AdminPPTSelection: ['AdminModels'],
|
||||
AdminPolicyEditor: ['AdminModels', 'AdminStore'],
|
||||
};
|
||||
|
||||
function run(command, args) {
|
||||
const result = spawnSync(command, args, { cwd: root, stdio: 'inherit' });
|
||||
if (result.error) throw result.error;
|
||||
if (result.status !== 0) process.exit(result.status ?? 1);
|
||||
}
|
||||
|
||||
if (!process.argv.includes('--render-only')) {
|
||||
for (const [name, sources] of Object.entries(cases)) {
|
||||
const binary = join(output, name);
|
||||
run('swiftc', [...sources.map(source => `reimburse/${source}.swift`), `tests/${name}Tests.swift`, '-o', binary]);
|
||||
run(binary, []);
|
||||
}
|
||||
console.log(`${Object.keys(cases).length} Swift test suites passed.`);
|
||||
}
|
||||
|
||||
if (process.argv.includes('--render') || process.argv.includes('--render-only')) {
|
||||
const sources = readdirSync(join(root, 'reimburse'))
|
||||
.filter(name => name.endsWith('.swift') && name !== 'reimburseApp.swift')
|
||||
.map(name => `reimburse/${name}`);
|
||||
const binary = join(output, 'InterfaceSmokeTests');
|
||||
run('swiftc', [...sources, 'tests/InterfaceSmokeTests.swift', '-o', binary]);
|
||||
run(binary, [join(output, 'screenshots')]);
|
||||
}
|
||||
console.log(`Validation output: ${output}`);
|
||||
Reference in New Issue
Block a user