fix(bazel): support --nolegacy_external_runfiles in protractor rule (#26708)

PR Close #26708
This commit is contained in:
Greg Magolan 2018-10-23 18:02:43 -07:00 committed by Alex Rickabaugh
parent bf9ab53f12
commit 7f39f37003
5 changed files with 24 additions and 28 deletions

View File

@ -21,12 +21,12 @@ def rules_angular_dependencies():
#
# Download Bazel toolchain dependencies as needed by build actions
#
# TODO(gmagolan): updated to next tagged rules_typescript release
_maybe(
http_archive,
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.20.3.zip",
strip_prefix = "rules_typescript-0.20.3",
sha256 = "2a03b23c30c5109ab0863cfa60acce73ceb56337d41efc2dd67f8455a1c1d5f3",
url = "https://github.com/bazelbuild/rules_typescript/archive/8ea1a55cf5cf8be84ddfeefc0940769b80da792f.zip",
strip_prefix = "rules_typescript-8ea1a55cf5cf8be84ddfeefc0940769b80da792f",
)
# Needed for Remote Execution

View File

@ -19,8 +19,8 @@ Fulfills similar role as the package.json file.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# This file mirrored from https://raw.githubusercontent.com/bazelbuild/rules_nodejs/0.15.1/package.bzl
VERSION = "0.15.1"
# This file mirrored from https://raw.githubusercontent.com/bazelbuild/rules_nodejs/0.15.3/package.bzl
VERSION = "0.15.3"
def rules_nodejs_dependencies():
"""

View File

@ -35,9 +35,8 @@ def rules_typescript_dependencies():
_maybe(
http_archive,
name = "build_bazel_rules_nodejs",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/0.15.1.zip"],
sha256 = "a0a91a2e0cee32e9304f1aeea9e6c1b611afba548058c5980217d44ee11e3dd7",
strip_prefix = "rules_nodejs-0.15.1",
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/0.15.3.zip"],
strip_prefix = "rules_nodejs-0.15.3",
)
# ts_web_test depends on the web testing rules to provision browsers.

View File

@ -100,7 +100,8 @@ if (process.env['WEB_TEST_METADATA']) {
const webTestNamedFiles = webTestMetadata['webTestFiles'][0]['namedFiles'];
const headless = !process.env['DISPLAY'];
if (webTestNamedFiles['CHROMIUM']) {
const chromeBin = path.join(process.cwd(), 'external', webTestNamedFiles['CHROMIUM']);
const chromeBin = require.resolve(webTestNamedFiles['CHROMIUM']);
const chromeDriver = require.resolve(webTestNamedFiles['CHROMEDRIVER']);
const args = [];
if (headless) {
args.push('--headless');
@ -109,7 +110,7 @@ if (process.env['WEB_TEST_METADATA']) {
setConf(conf, 'directConnect', true, 'is set to true for chrome');
setConf(
conf, 'chromeDriver',
path.join(process.cwd(), 'external', webTestNamedFiles['CHROMEDRIVER']),
chromeDriver,
'is determined by the browsers attribute');
setConf(
conf, 'capabilities', {
@ -125,7 +126,7 @@ if (process.env['WEB_TEST_METADATA']) {
// TODO(gmagolan): implement firefox support for protractor
throw new Error('Firefox not yet support by protractor_web_test_suite');
// const firefoxBin = path.join('external', webTestNamedFiles['FIREFOX']);
// const firefoxBin = require.resolve(webTestNamedFiles['FIREFOX'])
// const args = [];
// if (headless) {
// args.push("--headless")

View File

@ -15,6 +15,12 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
_CONF_TMPL = "//packages/bazel/src/protractor:protractor.conf.js"
def _short_path_to_manifest_path(ctx, short_path):
if short_path.startswith("../"):
return short_path[3:]
else:
return ctx.workspace_name + "/" + short_path
def _protractor_web_test_impl(ctx):
configuration = ctx.actions.declare_file(
"%s.conf.js" % ctx.label.name,
@ -53,16 +59,6 @@ def _protractor_web_test_impl(ctx):
if hasattr(ctx.attr.on_prepare, "typescript"):
on_prepare_file = ctx.attr.on_prepare.typescript.es5_sources.to_list()[0]
protractor_executable_path = ctx.executable.protractor.short_path
if protractor_executable_path.startswith(".."):
protractor_executable_path = "external" + protractor_executable_path[2:]
server_executable_path = ""
if ctx.executable.server:
server_executable_path = ctx.executable.server.short_path
if server_executable_path.startswith(".."):
server_executable_path = "external" + protractor_executable_path[2:]
ctx.actions.expand_template(
output = configuration,
template = ctx.file._conf_tmpl,
@ -70,7 +66,7 @@ def _protractor_web_test_impl(ctx):
"TMPL_config": expand_path_into_runfiles(ctx, configuration_file.short_path) if configuration_file else "",
"TMPL_on_prepare": expand_path_into_runfiles(ctx, on_prepare_file.short_path) if on_prepare_file else "",
"TMPL_workspace": ctx.workspace_name,
"TMPL_server": server_executable_path,
"TMPL_server": ctx.executable.server.short_path if ctx.executable.server else "",
"TMPL_specs": "\n".join([" '%s'," % e for e in specs]),
},
)
@ -84,15 +80,15 @@ def _protractor_web_test_impl(ctx):
if [ -e "$RUNFILE_MANIFEST_FILE" ]; then
while read line; do
declare -a PARTS=($line)
if [ "${{PARTS[0]}}" == "angular/{TMPL_protractor}" ]; then
if [ "${{PARTS[0]}}" == "{TMPL_protractor}" ]; then
readonly PROTRACTOR=${{PARTS[1]}}
elif [ "${{PARTS[0]}}" == "angular/{TMPL_conf}" ]; then
elif [ "${{PARTS[0]}}" == "{TMPL_conf}" ]; then
readonly CONF=${{PARTS[1]}}
fi
done < $RUNFILE_MANIFEST_FILE
else
readonly PROTRACTOR={TMPL_protractor}
readonly CONF={TMPL_conf}
readonly PROTRACTOR=../{TMPL_protractor}
readonly CONF=../{TMPL_conf}
fi
export HOME=$(mktemp -d)
@ -104,8 +100,8 @@ echo "Protractor $PROTRACTOR_VERSION"
# Run the protractor binary
$PROTRACTOR $CONF
""".format(
TMPL_protractor = protractor_executable_path,
TMPL_conf = configuration.short_path,
TMPL_protractor = _short_path_to_manifest_path(ctx, ctx.executable.protractor.short_path),
TMPL_conf = _short_path_to_manifest_path(ctx, configuration.short_path),
),
)
return [DefaultInfo(