| load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") |
| load("@bazel_skylib//rules:build_test.bzl", "build_test") |
| load("@npm//:defs.bzl", "npm_link_all_packages") |
| load(":generated_pkg_json_test.bzl", "generated_pkg_json_test") |
| load(":npm_auth_test.bzl", "npm_auth_test_suite") |
| load(":npmrc_test.bzl", "npmrc_tests") |
| load(":parse_pnpm_lock_tests.bzl", "parse_pnpm_lock_tests") |
| load(":pnpm_test.bzl", "pnpm_tests") |
| load(":transitive_closure_tests.bzl", "transitive_closure_tests") |
| load(":translate_lock_helpers_tests.bzl", "translate_lock_helpers_tests") |
| load(":utils_tests.bzl", "utils_tests") |
| |
| npm_link_all_packages(name = "node_modules") |
| |
| # Unit tests |
| utils_tests(name = "test_utils") |
| |
| npmrc_tests(name = "test_npmrc") |
| |
| pnpm_tests(name = "test_pnpm") |
| |
| transitive_closure_tests(name = "test_transitive_closure") |
| |
| translate_lock_helpers_tests(name = "test_translate_lock") |
| |
| parse_pnpm_lock_tests(name = "test_parse_pnpm_lock") |
| |
| generated_pkg_json_test(name = "test_generated_pkg_json") |
| |
| npm_auth_test_suite() |
| |
| write_source_files( |
| name = "write_npm_translate_lock", |
| files = { |
| "snapshots/npm_defs.bzl": "@npm//:defs.bzl", |
| "snapshots/unused_links_defs.bzl": "@npm__unused__0.2.2__links//:defs.bzl", |
| "snapshots/fsevents_links_defs.bzl": "@npm__fsevents__2.3.2__links//:defs.bzl", |
| "snapshots/rollup_links_defs.bzl": "@npm__rollup__2.70.2__links//:defs.bzl", |
| "snapshots/package_json.bzl": "@npm__rollup__2.70.2//examples/npm_deps:package_json.bzl", |
| "snapshots/package_json_with_dashes.bzl": "@npm__webpack-bundle-analyzer__4.5.0_bufferutil_4.0.8//npm/private/test:package_json.bzl", |
| }, |
| tags = [ |
| "skip-on-bazel6", |
| "skip-on-bazel8", |
| ], |
| ) |
| |
| build_test( |
| name = "node_modules_test", |
| targets = [ |
| # @kubernetes/client-node: has a "prepare" lifecycle hook that runs tsc |
| # lodash: brought in as a vendored .tgz file: vendored/lodash-4.17.21.tgz |
| # puppeteer: has a bin entry in the transitive closure with two segments: @puppeteer/browsers in https://unpkg.com/@puppeteer/browsers@0.5.0/package.json |
| # segfault-handler: has a node-gyp install step |
| ":node_modules", |
| |
| # @fastify/send (@3.3.0) contains spaces and a ☃ character in paths |
| ":node_modules/@fastify/send", |
| ], |
| ) |
| |
| sh_test( |
| name = "bin_test", |
| srcs = ["bin_test.sh"], |
| args = ["$(NODE_PATH)"], |
| data = [ |
| # Test that node_modules/.bin binaries work in both the root package |
| # and in subpackages. The relative paths in the two are different since the |
| # actual node entry is in the package store which is in the root package. |
| "//:node_modules/typescript", |
| ":node_modules/typescript", |
| # This eager toolchain fetching could be cleaed up in the future |
| "@nodejs_darwin_amd64//:node_files", |
| "@nodejs_darwin_arm64//:node_files", |
| "@nodejs_linux_amd64//:node_files", |
| "@nodejs_linux_arm64//:node_files", |
| ], |
| toolchains = ["@nodejs_toolchains//:resolved_toolchain"], |
| ) |