From 12f711a0b0281dd67a479bac91d16bba95506089 Mon Sep 17 00:00:00 2001 From: Ryan Day Date: Wed, 11 Sep 2019 08:34:22 -0700 Subject: [PATCH] fix: add missing async test fixes --- internal/linker/link_node_modules.ts | 2 +- internal/linker/test/link_node_modules.spec.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/linker/link_node_modules.ts b/internal/linker/link_node_modules.ts index c6a5cbcce1..d522808eff 100644 --- a/internal/linker/link_node_modules.ts +++ b/internal/linker/link_node_modules.ts @@ -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. diff --git a/internal/linker/test/link_node_modules.spec.ts b/internal/linker/test/link_node_modules.spec.ts index 0262e8fbcc..b729db74cf 100644 --- a/internal/linker/test/link_node_modules.spec.ts +++ b/internal/linker/test/link_node_modules.spec.ts @@ -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); @@ -62,7 +62,7 @@ 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()); @@ -70,7 +70,7 @@ describe('link_node_modules', () => { .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'); @@ -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));