Skip to content

Commit

Permalink
fix(bazel): do not put temporary test folders next to test files
Browse files Browse the repository at this point in the history
Currently the tool mappings and temporary environment directories
of integration tests are always put directly into the test files
directory. e.g.

```
<tmp>/.tool-mapping/node
<tmp>/package.json
```

This worked fine in general but some tests might accidentally discover
the `.tool-mapping-X` folder we created. This shouldn't happen as its
an artifact of our integration test infrastructure.

We can fix this by separating these folders into a structure like:

```
<tmp>/.tool-mapping/node
<tmp>/test-sandbox/package.json
```

The test can then just run one folder deeper, in the `test-sandbox`
folder.
  • Loading branch information
devversion committed Jul 11, 2022
1 parent 7b43ff7 commit 6b5886c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bazel/integration/test_runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ export class TestRunner {

async run() {
const testTmpDir = await this._getTestTmpDirectoryPath();
const testWorkingDir = path.join(testTmpDir, this.testPackageRelativeWorkingDir);
const testSandboxDir = path.join(testTmpDir, 'test-sandbox');
const testWorkingDir = path.join(testSandboxDir, this.testPackageRelativeWorkingDir);

// Create the test sandbox directory. The working directory does not need to
// be explicitly created here as the test file copying should create the folder.
await fs.promises.mkdir(testSandboxDir);

const toolMappings = await this._setupToolMappingsForTest(testTmpDir);
const testEnv = await this._buildTestProcessEnvironment(testTmpDir, toolMappings.binDir);

debug(`Copying test fixtures into: ${path.normalize(testTmpDir)}`);
debug(`Temporary directory for integration test: ${path.normalize(testTmpDir)}`);
debug(`Test files are copied into: ${path.normalize(testSandboxDir)}`);
console.info(`Running test in directory: ${path.normalize(testWorkingDir)}`);

await this._copyTestFilesToDirectory(testTmpDir);
await this._copyTestFilesToDirectory(testSandboxDir);
await this._patchPackageJsonIfNeeded(testWorkingDir);
await this._runTestCommands(testWorkingDir, testEnv);
}
Expand Down

0 comments on commit 6b5886c

Please sign in to comment.