Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Jun 29, 2023
1 parent ad16a88 commit 1e28aac
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tests-integration/tests/baseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export type TestOptions = {

type TestFixtures = TestOptions & {
workbox: Page,
createProject: () => Promise<string>
createProject: () => Promise<string>,
createTempDir: () => Promise<string>,
};

export const test = base.extend<TestFixtures>({
vscodeVersion: ['insiders', { option: true }],
workbox: async ({ vscodeVersion, createProject }, use) => {
const defaultCachePath = test.info().outputPath('cache');
await fs.promises.mkdir(defaultCachePath);
workbox: async ({ vscodeVersion, createProject, createTempDir }, use) => {
const defaultCachePath = await createTempDir();
const vscodePath = await downloadAndUnzipVSCode(vscodeVersion);
const electronApp = await _electron.launch({
executablePath: vscodePath,
Expand Down Expand Up @@ -63,12 +63,10 @@ export const test = base.extend<TestFixtures>({
test.info().attachments.push({ name: 'trace', path: tracePath, contentType: 'application/zip' });
await electronApp.close();
},
createProject: async ({ }, use) => {
const projects: string[] = [];
createProject: async ({ createTempDir }, use) => {
await use(async () => {
// We want to be outside of the project directory to avoid already installed dependencies.
const projectPath = path.join(await fs.promises.realpath(os.tmpdir()), `pwtest-vscode-${test.info().workerIndex}`);
projects.push(projectPath);
const projectPath = await createTempDir();
if (fs.existsSync(projectPath))
await fs.promises.rm(projectPath, { recursive: true });
console.log(`Creating project in ${projectPath}`);
Expand All @@ -80,7 +78,15 @@ export const test = base.extend<TestFixtures>({
});
return projectPath;
});
for (const project of projects)
await fs.promises.rm(project, { recursive: true });
},
createTempDir: async ({ }, use) => {
const tempDirs: string[] = [];
await use(async () => {
const tempDir = await fs.promises.realpath(await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pwtest-')));
tempDirs.push(tempDir);
return tempDir;
});
for (const tempDir of tempDirs)
await fs.promises.rm(tempDir, { recursive: true });
}
});

0 comments on commit 1e28aac

Please sign in to comment.