Skip to content

Commit f938ab7

Browse files
committed
fix(builtin): bin folder was included in runfiles path for tests when link type was 'bin'
1 parent 6fad0a5 commit f938ab7

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

internal/linker/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ Include as much of the build output as you can without disclosing anything confi
172172
const pkg = target.split(':')[0];
173173
this.packagePath = path.posix.join(wksp, pkg);
174174
}
175+
// If under runfiles (and not unit testing) then don't add a bin to taget for bin links
176+
this.noBin = !!env['TEST_TARGET'] && wksp !== 'build_bazel_rules_nodejs' &&
177+
target !== '//internal/linker/test:unit_tests';
175178
}
176179
lookupDirectory(dir) {
177180
if (!this.manifest)
@@ -422,7 +425,8 @@ Include as much of the build output as you can without disclosing anything confi
422425
switch (root) {
423426
case 'bin':
424427
// FIXME(#1196)
425-
target = path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
428+
target = runfiles.noBin ? path.join(workspaceAbs, toWorkspaceDir(modulePath)) :
429+
path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
426430
break;
427431
case 'src':
428432
target = path.join(workspaceAbs, toWorkspaceDir(modulePath));

internal/linker/link_node_modules.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ async function resolveRoot(root: string|undefined, runfiles: Runfiles) {
126126
export class Runfiles {
127127
manifest: Map<string, string>|undefined;
128128
dir: string|undefined;
129+
noBin: boolean;
129130
/**
130131
* If the environment gives us enough hints, we can know the path to the package
131132
* in the form workspace_name/path/to/package
@@ -166,6 +167,10 @@ export class Runfiles {
166167
const pkg = target.split(':')[0];
167168
this.packagePath = path.posix.join(wksp, pkg);
168169
}
170+
171+
// If under runfiles (and not unit testing) then don't add a bin to taget for bin links
172+
this.noBin = !!env['TEST_TARGET'] && wksp !== 'build_bazel_rules_nodejs' &&
173+
target !== '//internal/linker/test:unit_tests';
169174
}
170175

171176
lookupDirectory(dir: string): string|undefined {
@@ -487,7 +492,8 @@ export async function main(args: string[], runfiles: Runfiles) {
487492
switch (root) {
488493
case 'bin':
489494
// FIXME(#1196)
490-
target = path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
495+
target = runfiles.noBin ? path.join(workspaceAbs, toWorkspaceDir(modulePath)) :
496+
path.join(workspaceAbs, bin, toWorkspaceDir(modulePath));
491497
break;
492498
case 'src':
493499
target = path.join(workspaceAbs, toWorkspaceDir(modulePath));

0 commit comments

Comments
 (0)