Skip to content

Commit a706d1d

Browse files
committed
Make test restore file content
1 parent 1f91789 commit a706d1d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

integration/vscode/ada/test/suite/general/extension.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getProjectFile, getObjectDir } from '../../../src/helpers';
55
import { assertEqualToFileContent, activate } from '../utils';
66

77
import * as vscode from 'vscode';
8+
import { readFileSync, writeFileSync } from 'fs';
89

910
suite('Extensions Test Suite', function () {
1011
// Make sure the extension is activated
@@ -38,6 +39,7 @@ suite('Extensions Test Suite', function () {
3839
];
3940
const folder = vscode.workspace.workspaceFolders[0].uri;
4041
const fileUri = vscode.Uri.joinPath(folder, 'src', 'test_subprogram_box.adb');
42+
const contentBefore = readFileSync(fileUri.fsPath);
4143
const expectedUri = vscode.Uri.joinPath(folder, 'src', 'test_subprogram_box.expected');
4244

4345
for (const cursorPos of cursorPositions) {
@@ -47,8 +49,16 @@ suite('Extensions Test Suite', function () {
4749
await vscode.commands.executeCommand('ada.subprogramBox');
4850
}
4951
const editorText = vscode.window.activeTextEditor?.document.getText() ?? '';
52+
vscode.window.activeTextEditor?.hide();
5053

51-
assertEqualToFileContent(editorText, expectedUri);
54+
try {
55+
assertEqualToFileContent(editorText, expectedUri);
56+
} finally {
57+
/**
58+
* Restore the old file content
59+
*/
60+
writeFileSync(fileUri.fsPath, contentBefore);
61+
}
5262
} else {
5363
throw new Error('No workspace folder found for the specified URI');
5464
}

0 commit comments

Comments
 (0)