Skip to content

Commit

Permalink
fix(builtin): bin folder was included in runfiles path for tests when…
Browse files Browse the repository at this point in the history
… link type was 'bin'
  • Loading branch information
gregmagolan committed Dec 20, 2019
1 parent 6fad0a5 commit f938ab7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/linker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ Include as much of the build output as you can without disclosing anything confi
const pkg = target.split(':')[0];
this.packagePath = path.posix.join(wksp, pkg);
}
// If under runfiles (and not unit testing) then don't add a bin to taget for bin links
this.noBin = !!env['TEST_TARGET'] && wksp !== 'build_bazel_rules_nodejs' &&
target !== '//internal/linker/test:unit_tests';
}
lookupDirectory(dir) {
if (!this.manifest)
Expand Down Expand Up @@ -422,7 +425,8 @@ Include as much of the build output as you can without disclosing anything confi
switch (root) {
case 'bin':
// FIXME(#1196)
target = path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
target = runfiles.noBin ? path.join(workspaceAbs, toWorkspaceDir(modulePath)) :
path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
break;
case 'src':
target = path.join(workspaceAbs, toWorkspaceDir(modulePath));
Expand Down
8 changes: 7 additions & 1 deletion internal/linker/link_node_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ async function resolveRoot(root: string|undefined, runfiles: Runfiles) {
export class Runfiles {
manifest: Map<string, string>|undefined;
dir: string|undefined;
noBin: boolean;
/**
* If the environment gives us enough hints, we can know the path to the package
* in the form workspace_name/path/to/package
Expand Down Expand Up @@ -166,6 +167,10 @@ export class Runfiles {
const pkg = target.split(':')[0];
this.packagePath = path.posix.join(wksp, pkg);
}

// If under runfiles (and not unit testing) then don't add a bin to taget for bin links
this.noBin = !!env['TEST_TARGET'] && wksp !== 'build_bazel_rules_nodejs' &&
target !== '//internal/linker/test:unit_tests';
}

lookupDirectory(dir: string): string|undefined {
Expand Down Expand Up @@ -487,7 +492,8 @@ export async function main(args: string[], runfiles: Runfiles) {
switch (root) {
case 'bin':
// FIXME(#1196)
target = path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
target = runfiles.noBin ? path.join(workspaceAbs, toWorkspaceDir(modulePath)) :
path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
break;
case 'src':
target = path.join(workspaceAbs, toWorkspaceDir(modulePath));
Expand Down

0 comments on commit f938ab7

Please sign in to comment.