| 37 | } |
| 38 | |
| 39 | async function snapshotTest({scopeName, grammarFiles, testFile}: TestCase): Promise<number> { |
| 40 | grammarFiles.push(...DUMMY_GRAMMARS); |
| 41 | const grammarOptions = grammarFiles.reduce((acc, file) => [...acc, '-g', file], [] as string[]); |
| 42 | |
| 43 | const resolvedTestFile = process.env.BUILD_WORKSPACE_DIRECTORY |
| 44 | ? path.join(process.env.BUILD_WORKSPACE_DIRECTORY, 'vscode-ng-language-service', testFile) |
| 45 | : testFile; |
| 46 | |
| 47 | const options = [ |
| 48 | 'node_modules/vscode-tmgrammar-test/dist/snapshot.js', |
| 49 | '-s', |
| 50 | scopeName, |
| 51 | ...grammarOptions, |
| 52 | resolvedTestFile, |
| 53 | ]; |
| 54 | |
| 55 | if (process.argv.includes('-u')) { |
| 56 | options.push('-u'); |
| 57 | } |
| 58 | |
| 59 | return spawn('node', options, {stdio: 'inherit' /* use parent process IO */}).catch( |
| 60 | (code) => code, |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | describe('snapshot tests', () => { |
| 65 | for (let tc of cases) { |