Skip to content

Commit

Permalink
fix: add missing async test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
soldair authored and alexeagle committed Sep 11, 2019
1 parent 9a02ee0 commit 12f711a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/linker/link_node_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function symlink(target: string, path: string) {
try{
await fs.promises.symlink(target, path, 'junction');
} catch(e){
if(e.code !== 'ENOENT'){
if(e.code !== 'EEXIST'){
throw e;
}
// We assume here that the path is already linked to the correct target.
Expand Down
16 changes: 8 additions & 8 deletions internal/linker/test/link_node_modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ describe('link_node_modules', () => {
mkdirp(workspace);
});

it('should report when modules manifest absent', () => {
it('should report when modules manifest absent',async () => {
try {
(linker as any).main();
await (linker as any).main();
} catch (expected) {
expect(expected.message).toContain('requires one argument');
}
try {
(linker as any).main([]);
await (linker as any).main([]);
} catch (expected) {
expect(expected.message).toContain('requires one argument');
}
try {
(linker as any).main(['bad_path']);
await (linker as any).main(['bad_path']);
} catch (expected) {
expect(expected.message).toContain('ENOENT');
}
});

it('should handle first-party packages in workspace', () => {
it('should handle first-party packages in workspace', async() => {
// Set the cwd() like Bazel would in the execroot
process.chdir(workspace);

Expand All @@ -62,15 +62,15 @@ describe('link_node_modules', () => {
'workspace': workspace,
});

linker.main(['manifest.json'], {dir: process.env['RUNFILES_DIR']} as any);
await linker.main(['manifest.json'], {dir: process.env['RUNFILES_DIR']} as any);

// The linker expects to run as its own process, so it changes the wd
process.chdir(path.join());
expect(fs.readdirSync(path.join(process.env['TEST_TMPDIR']!, workspace, 'node_modules', 'a')))
.toContain('index.js');
});

it('should handle third-party packages in runfiles', () => {
it('should handle third-party packages in runfiles', async () => {
mkdirp('npm/node_modules/some-package');
const idx = 'npm/node_modules/some-package/index.js';
fs.writeFileSync(idx, 'exports = {}', 'utf-8');
Expand All @@ -82,7 +82,7 @@ describe('link_node_modules', () => {
writeManifest({'root': 'npm/node_modules'});
writeRunfiles(runfilesManifest);

linker.main(['manifest.json'], new linker.Runfiles());
await linker.main(['manifest.json'], new linker.Runfiles());

// The linker expects to run as its own process, so it changes the wd
process.chdir(path.join(process.env['TEST_TMPDIR']!, workspace));
Expand Down

0 comments on commit 12f711a

Please sign in to comment.