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

bazel e2e test prefactors #24337

Merged
merged 2 commits into from Nov 29, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/build-bazel.ts
Expand Up @@ -139,7 +139,7 @@ export default async function (
for (const target of targets) {
const packageDir = target.replace(/\/\/packages\/(.*):npm_package_archive/, '$1');
const bazelOutDir = join(bazelBin, 'packages', packageDir, 'npm_package');
const tarPath = `${bazelBin}/packages/${packageDir}/npm_package_archive.tar.gz`;
const tarPath = `${bazelBin}/packages/${packageDir}/npm_package_archive.tgz`;
const packageJsonPath = `${bazelOutDir}/package.json`;
const packageName = require(packageJsonPath).name;
const destDir = `${distRoot}/${packageName}`;
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/utils/process.ts
Expand Up @@ -345,15 +345,15 @@ export function globalNpm(args: string[], env?: NodeJS.ProcessEnv) {
);
}

return _exec({ silent: true, env }, 'node', [require.resolve('npm'), ...args]);
return _exec({ silent: true, env }, process.execPath, [require.resolve('npm'), ...args]);
}

export function npm(...args: string[]) {
return _exec({}, 'npm', args);
}

export function node(...args: string[]) {
return _exec({}, 'node', args);
return _exec({}, process.execPath, args);
}

export function git(...args: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/utils/project.ts
Expand Up @@ -67,7 +67,7 @@ export async function prepareProjectForE2e(name: string) {
// Often fails the first time so attempt twice if necessary.
const runWebdriverUpdate = () =>
exec(
'node',
process.execPath,
'node_modules/protractor/bin/webdriver-manager',
'update',
'--standalone',
Expand Down
12 changes: 8 additions & 4 deletions tests/legacy-cli/e2e/utils/registry.ts
Expand Up @@ -19,10 +19,14 @@ export async function createNpmRegistry(
configContent = configContent.replace(/\$\{HTTPS_PORT\}/g, String(httpsPort));
await writeFile(join(registryPath, 'verdaccio.yaml'), configContent);

return spawn('node', [require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'], {
cwd: registryPath,
stdio: 'inherit',
});
return spawn(
process.execPath,
[require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'],
{
cwd: registryPath,
stdio: 'inherit',
},
);
}

// Token was generated using `echo -n 'testing:s3cret' | openssl base64`.
Expand Down
6 changes: 3 additions & 3 deletions tools/defaults.bzl
Expand Up @@ -59,7 +59,7 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs):
in the same folder to exist.

Args:
name: Name of the pkg_npm rule. '_archive.tar.gz' is appended to create the tarball.
name: Name of the pkg_npm rule. '_archive.tgz' is appended to create the tarball.
pkg_deps: package.json files of dependent packages. These are used for local path substitutions when --config=local is set.
use_prodmode_output: False to ship ES5 devmode output, True to ship ESM output. Defaults to False.
**kwargs: Additional arguments passed to the real pkg_npm.
Expand Down Expand Up @@ -116,7 +116,7 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs):
)

# Copy package.json files to bazel-out so we can use their bazel-out paths to determine
# the corresponding package npm package tar.gz path for substitutions.
# the corresponding package npm package tgz path for substitutions.
copy_to_bin(
name = "package_json_copy",
srcs = [pkg_json],
Expand Down Expand Up @@ -195,7 +195,7 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs):
pkg_tar(
name = name + "_archive",
srcs = [":%s" % name],
extension = "tar.gz",
extension = "tgz",
strip_prefix = "./%s" % name,
visibility = visibility,
)
6 changes: 3 additions & 3 deletions tools/link_package_json_to_tarballs.bzl
Expand Up @@ -8,7 +8,7 @@ load("@aspect_bazel_lib//lib:utils.bzl", "to_label")
def link_package_json_to_tarballs(name, src, pkg_deps, out):
"""Substitute tar paths into a package.json file for the packages it depends on.

src and pkg_deps must be labels in the bazel-out tree for the derived path to the npm_package_archive.tar.gz to be correct.
src and pkg_deps must be labels in the bazel-out tree for the derived path to the npm_package_archive.tgz to be correct.

Args:
name: Name of the rule
Expand Down Expand Up @@ -41,7 +41,7 @@ def link_package_json_to_tarballs(name, src, pkg_deps, out):
# for the tar for this package as that would create a circular dependency.
pkg_label = to_label(pkg_dep)
if pkg_label.package != src_pkg:
pkg_tar = "@%s//%s:npm_package_archive.tar.gz" % (pkg_label.workspace_name, pkg_label.package)
pkg_tar = "@%s//%s:npm_package_archive.tgz" % (pkg_label.workspace_name, pkg_label.package)
srcs.append(pkg_tar)

# Deriving the absolute path to the tar in the execroot requries different
Expand All @@ -53,7 +53,7 @@ def link_package_json_to_tarballs(name, src, pkg_deps, out):
name = "%s_%s_filter" % (name, i),
srcs = srcs,
cmd = """
TAR=$$(dirname $$({abs_path_sandbox} || {abs_path_nosandbox}))/npm_package_archive.tar.gz
TAR=$$(dirname $$({abs_path_sandbox} || {abs_path_nosandbox}))/npm_package_archive.tgz
PKGNAME=$$(cat $(execpath {pkg_name}))
if [[ "$$TAR" != *bazel-out* ]]; then
echo "ERROR: package.json passed to substitute_tar_deps must be in the output tree. You can use copy_to_bin to copy a source file to the output tree."
Expand Down