|
1 | 1 | import * as assert from 'assert'; |
| 2 | +import * as fs from 'fs'; |
| 3 | +import * as os from 'os'; |
2 | 4 | import * as path from 'path'; |
3 | 5 | import * as vscode from 'vscode'; |
4 | 6 |
|
5 | 7 | suite('CheckModel cancellation handling', () => { |
| 8 | + const fsp = fs.promises; |
6 | 9 | const tla2toolsPath = require.resolve(path.resolve(__dirname, '../../../src/tla2tools')); |
7 | 10 | const checkModelPath = require.resolve(path.resolve(__dirname, '../../../src/commands/checkModel')); |
8 | 11 | const modelPath = require.resolve(path.resolve(__dirname, '../../../src/model/check')); |
@@ -71,12 +74,21 @@ suite('CheckModel cancellation handling', () => { |
71 | 74 | const { doCheckModel, CTX_TLC_CAN_RUN_AGAIN, CTX_TLC_RUNNING } = await import(checkModelPath); |
72 | 75 | const { SpecFiles } = await import(modelPath); |
73 | 76 |
|
74 | | - const specFiles = new SpecFiles('Dummy.tla', 'Dummy.cfg'); |
75 | | - const diagnostics = vscode.languages.createDiagnosticCollection('cancel-test'); |
| 77 | + const tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'check-model-cancel-')); |
| 78 | + const tlaFile = path.join(tmpDir, 'Dummy.tla'); |
| 79 | + const cfgFile = path.join(tmpDir, 'Dummy.cfg'); |
| 80 | + await fsp.writeFile(tlaFile, '---- MODULE Dummy ----\n====\n'); |
| 81 | + await fsp.writeFile(cfgFile, 'SPECIFICATION Spec\n'); |
76 | 82 |
|
77 | | - await doCheckModel(specFiles, true, {} as vscode.ExtensionContext, diagnostics, true); |
| 83 | + const specFiles = new SpecFiles(tlaFile, cfgFile); |
| 84 | + const diagnostics = vscode.languages.createDiagnosticCollection('cancel-test'); |
78 | 85 |
|
79 | | - diagnostics.dispose(); |
| 86 | + try { |
| 87 | + await doCheckModel(specFiles, true, {} as vscode.ExtensionContext, diagnostics, true); |
| 88 | + } finally { |
| 89 | + diagnostics.dispose(); |
| 90 | + await fsp.rm(tmpDir, { recursive: true, force: true }); |
| 91 | + } |
80 | 92 |
|
81 | 93 | assert.strictEqual( |
82 | 94 | contextValues[CTX_TLC_RUNNING], |
|
0 commit comments