Skip to content

Commit

Permalink
Use existing pattern when running old visual-diff tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bearfriend committed Aug 24, 2023
1 parent 784cb1e commit fb2e9e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions bin/d2l-test-runner.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node
import commandLineArgs from 'command-line-args';
import { execSync } from 'node:child_process';
import process from 'node:process';
import { runner } from '../src/server/cli/test-runner.js';
import { execSync } from 'node:child_process';

const { argv, stdout } = process;
const cli = commandLineArgs({ name: 'subcommand', defaultOption: true }, { stopAtFirstUnknown: true, argv });
Expand All @@ -24,8 +24,10 @@ if (cli.subcommand === 'vdiff') {
await migrate.start(vdiff._unknown);
} else if (vdiff.subcommand === 'migrate-local') {

const { pattern = './**' } = commandLineArgs({ name: 'pattern', type: String, defaultOption: true }, { partial: true, argv: vdiff._unknown || [] });

execSync('npm install @brightspace-ui/visual-diff@14 --no-save');
execSync('npx mocha \'./**/*.visual-diff.js\' -t 10000 --golden');
execSync(`npx mocha '${pattern}/*.visual-diff.js' -t 10000 --golden`);

const { migrate } = await import('../src/server/cli/vdiff/migrate.js');
await migrate.start(vdiff._unknown, true);
Expand Down
5 changes: 4 additions & 1 deletion src/server/cli/vdiff/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ async function start(argv = [], local = false) {
await mkdir(newDir, { recursive: true });
return rename(file, join(newDir, newName));
}));
return rm(normalize(join(dir, '..', '..')), { recursive: true });

if (!local) {
return rm(normalize(join(dir, '..', '..')), { recursive: true });
}
}));

stdout.write(`\nMigrated ${fileCount} ${fileCount === 1 ? 'golden' : 'goldens'} found in ${dirs.length} test ${dirs.length === 1 ? 'directory' : 'directories'}\n`);
Expand Down

0 comments on commit fb2e9e5

Please sign in to comment.