From 7642abfb7afbf31a162ebcc4a72c37e29f80da1b Mon Sep 17 00:00:00 2001 From: Derek Cormier Date: Fri, 17 Jun 2022 10:44:16 -0700 Subject: [PATCH] build(bazel): fix bazel aio regressions after rebase The aio-bazel-migration branch was rebased onto main to include runfiles support on windows. --- aio/BUILD.bazel | 6 ++--- aio/karma.conf.js | 23 +++++++++++++++++++ aio/tests/e2e/protractor.conf.js | 23 +++++++++++++++++++ .../services/getImageDimensions.js | 2 +- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/aio/BUILD.bazel b/aio/BUILD.bazel index 04087708172..29b17e6e60a 100644 --- a/aio/BUILD.bazel +++ b/aio/BUILD.bazel @@ -182,7 +182,7 @@ architect( name = "build", args = [ "site:build:stable", - "--outputPath=../$(@D)", + "--output-path=../$(@D)", ], chdir = package_name(), configuration_env_vars = ["NG_BUILD_CACHE"], @@ -211,14 +211,14 @@ architect_test( name = "e2e", args = [ "site:e2e", - "--no-webdriverUpdate", + "--no-webdriver-update", ], chdir = package_name(), configuration_env_vars = ["NG_BUILD_CACHE"], data = E2E_FILES + E2E_DEPS, env = { - "CHROMEDRIVER_BIN": "../$(CHROMEDRIVER)", "CHROME_BIN": "../$(CHROMIUM)", + "CHROMEDRIVER_BIN": "../$(CHROMEDRIVER)", }, toolchains = [ "@aio_npm//@angular/dev-infra-private/bazel/browsers/chromium:toolchain_alias", diff --git a/aio/karma.conf.js b/aio/karma.conf.js index 5a6a8fc19f0..0e5efa968b4 100644 --- a/aio/karma.conf.js +++ b/aio/karma.conf.js @@ -1,6 +1,29 @@ // Karma configuration file, see link for more information // https://karma-runner.github.io/1.0/config/configuration-file.html +const os = require('os'); + +if (os.platform() === 'win32') { + /* + For some unknown reason, the symlinked copy of chromium under runfiles won't run under + karma on Windows. Instead, modify the CHROME_BIN env var to point to the chrome binary + under external/ in the execroot. + + CHROME_BIN is set to the make var $(CHROMIUM) in aio/BUILD.bazel, which points to chrome + under runfiles and thus starts with ../. Because we run architect with a chdir into aio, + $(CHROMIUM) additionally has a second ../. + + First, back out of + bazel-out/x64_windows-fastbuild/bin/aio/test.bat.runfiles/angular/aio + Then go into + external/ + and then into + org_chromium_chromium_windows/chrome-win + to cancel out the leading ../../ + */ + process.env.CHROME_BIN = `../../../../../../../external/org_chromium_chromium_windows/chrome-win/${process.env.CHROME_BIN}`; +} + module.exports = function (config) { config.set({ basePath: '', diff --git a/aio/tests/e2e/protractor.conf.js b/aio/tests/e2e/protractor.conf.js index fd173060f6b..25b6524547f 100644 --- a/aio/tests/e2e/protractor.conf.js +++ b/aio/tests/e2e/protractor.conf.js @@ -4,6 +4,29 @@ const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); const path = require('path') +const os = require('os'); + +if (os.platform() === 'win32') { + /* + For some unknown reason, the symlinked copy of chromium under runfiles won't run under + karma on Windows. Instead, modify the CHROME_BIN env var to point to the chrome binary + under external/ in the execroot. + + CHROME_BIN is set to the make var $(CHROMIUM) in aio/BUILD.bazel, which points to chrome + under runfiles and thus starts with ../. Because we run architect with a chdir into aio, + $(CHROMIUM) additionally has a second ../. + + First, back out of + bazel-out/x64_windows-fastbuild/bin/aio/e2e.bat.runfiles/angular/aio + Then go into + external/ + and then into + org_chromium_chromium_windows/chrome-win + to cancel out the leading ../../ + */ + process.env.CHROME_BIN = `../../../../../../../external/org_chromium_chromium_windows/chrome-win/${process.env.CHROME_BIN}`; +} + /** * @type { import("protractor").Config } */ diff --git a/aio/tools/transforms/angular-base-package/services/getImageDimensions.js b/aio/tools/transforms/angular-base-package/services/getImageDimensions.js index 8f047e040c6..705acf24111 100644 --- a/aio/tools/transforms/angular-base-package/services/getImageDimensions.js +++ b/aio/tools/transforms/angular-base-package/services/getImageDimensions.js @@ -6,7 +6,7 @@ module.exports = function getImageDimensions() { let error; for (const basePath of basePaths) { try { - return sizeOf(resolve(basePath, path)); + return sizeOf(join(basePath, path)); } catch (e) { // Fall back to next basePath if not found error = e;