Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(builtin): fix logic error in linker conflict resolution #1597

Merged
merged 1 commit into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/linker/link_node_modules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _link_mapping(label, mappings, k, v):
# v = ["bin", "angular/packages/compiler"]
if mappings[k][0] == "runfiles":
return True
elif v[0] != "runfiles":
elif v[0] == "runfiles":
return False
fail(("conflicting mapping at %s: %s maps to both %s and %s" % (label, k, mappings[k], v)), "deps")
else:
Expand Down
40 changes: 40 additions & 0 deletions internal/linker/test/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ linked(
testonly = True,
out = "actual_with_conflicts",
program = ":run_program",
# do not sort
deps = [
# NB: reference the copy of index.js in the output folder
"//%s/absolute_import:copy_to_bin" % package_name(),
# Intentinally include this before static_linked_pkg as order matters for the linker.
# The order here exercises a different code path in the linker conflict resolution logic
# than `example_with_conflicts_alt`.
":run_program",
# NB: static_linked maps to both
# ["runfiles", "build_bazel_rules_nodejs/internal/linker/test/integration/static_linked_pkg"] and
Expand All @@ -97,6 +101,35 @@ linked(
],
)

linked(
name = "example_with_conflicts_alt",
testonly = True,
out = "actual_with_conflicts_alt",
program = ":run_program",
# do not sort
deps = [
# NB: reference the copy of index.js in the output folder
"//%s/absolute_import:copy_to_bin" % package_name(),
# NB: static_linked maps to both
# ["runfiles", "build_bazel_rules_nodejs/internal/linker/test/integration/static_linked_pkg"] and
# ["bin", "build_bazel_rules_nodejs/internal/linker/test/integration/static_linked_pkg"]
# as the "runfiles" mapping comes from `:run_program`
"//internal/linker/test/integration/static_linked_pkg",
# NB: @linker_scoped/static_linked maps to both
# ["runfiles", "build_bazel_rules_nodejs/internal/linker/test/integration/static_linked_scoped_pkg"] and
# ["src", "build_bazel_rules_nodejs/internal/linker/test/integration/static_linked_scoped_pkg"]
# as the "runfiles" mapping comes from `:run_program`
"//internal/linker/test/integration/static_linked_scoped_pkg",
# Intentinally include this before static_linked_pkg as order matters for the linker.
# The order here exercises a different code path in the linker conflict resolution logic
# than `example_with_conflicts`.
":run_program",
"//internal/linker/test/integration/dynamic_linked_pkg",
"//internal/linker/test/integration/dynamic_linked_scoped_pkg",
"@npm//semver",
],
)

golden_file_test(
# default rule in this package
name = "integration",
Expand All @@ -110,3 +143,10 @@ golden_file_test(
actual = "actual_with_conflicts",
golden = "golden.txt",
)

golden_file_test(
# default rule in this package
name = "integration_conflicts_alt",
actual = "actual_with_conflicts_alt",
golden = "golden.txt",
)