Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved test cleanup and config management #1274

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/foam-vscode/src/test/run-tests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import rf from 'rimraf';
import path from 'path';
import { runTests } from 'vscode-test';
import { runUnit } from './suite-unit';
Expand Down Expand Up @@ -34,12 +35,21 @@ async function main() {
// Passed to --extensionTestsPath
const extensionTestsPath = path.join(__dirname, 'suite');

const testWorkspace = path.join(
extensionDevelopmentPath,
'.test-workspace'
);
// clean test workspace
rf.sync(path.join(testWorkspace, '*'));
rf.sync(path.join(testWorkspace, '.vscode'));
rf.sync(path.join(testWorkspace, '.foam'));

// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [
path.join(extensionDevelopmentPath, '.test-workspace'),
testWorkspace,
'--disable-extensions',
'--disable-workspace-trust',
],
Expand Down
4 changes: 2 additions & 2 deletions packages/foam-vscode/src/test/test-utils-vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ export const runCommand = async <T>(command: string, args: T = undefined) =>
* @param fn the function to execute
*/
export const withModifiedConfiguration = async (key, value, fn: () => void) => {
const old = vscode.workspace.getConfiguration().get(key);
const old = vscode.workspace.getConfiguration().inspect(key);
await vscode.workspace.getConfiguration().update(key, value);
await fn();
await vscode.workspace.getConfiguration().update(key, old);
await vscode.workspace.getConfiguration().update(key, old.workspaceValue);
};

/**
Expand Down
Loading