Bazel: Pass current host java runtime to sh_test rule
Change-Id: I5f41dc1d8c46160b6870a53544293c44531adc81
This commit is contained in:
parent
bdcd6de8d7
commit
042d70872f
|
@ -1,15 +1,12 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
DUMMY = ["dummy.sh"]
|
||||
|
||||
# Enable prologtests on newer Java versions again, when this Bazel bug is fixed:
|
||||
# https://github.com/bazelbuild/bazel/issues/9391
|
||||
sh_test(
|
||||
name = "test_examples",
|
||||
srcs = select({
|
||||
"//:java11": DUMMY,
|
||||
"//:java_next": DUMMY,
|
||||
"//conditions:default": ["run.sh"],
|
||||
}),
|
||||
data = glob(["*.pl"]) + ["//:gerrit.war"],
|
||||
srcs = ["run.sh"],
|
||||
args = ["$(JAVA)"],
|
||||
data = glob(["*.pl"]) + [
|
||||
"//:gerrit.war",
|
||||
"@bazel_tools//tools/jdk:current_host_java_runtime",
|
||||
],
|
||||
toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"],
|
||||
)
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
# TODO(davido): Figure out what to do if running alone and not invoked from bazel
|
||||
# $1 is equal to the $(JAVABASE)/bin/java make variable
|
||||
JAVA=$1
|
||||
|
||||
# Checks whether or not the $1 is starting with a slash: '/' and thus considered to be
|
||||
# an absolute path. If it is, then it is left as is, if it isn't then "$PWD/ is prepended
|
||||
# (in sh_test case it is relative and thus the runfiles directory is prepended).
|
||||
[[ "$JAVA" =~ ^(/|[^/]+$) ]] || JAVA="$PWD/$JAVA"
|
||||
|
||||
TESTS="t1 t2 t3"
|
||||
|
||||
# Note that both t1.pl and t2.pl test code in rules.pl.
|
||||
|
@ -36,7 +45,7 @@ do
|
|||
# Unit tests do not need to define clauses in packages.
|
||||
# Use one prolog-shell per unit test, to avoid name collision.
|
||||
echo "### Running test ${T}.pl"
|
||||
echo "[$T]." | java -jar ${GERRIT_WAR} prolog-shell -q -s load.pl
|
||||
echo "[$T]." | "${JAVA}" -jar ${GERRIT_WAR} prolog-shell -q -s load.pl
|
||||
|
||||
if [ "x$?" != "x0" ]; then
|
||||
echo "### Test ${T}.pl failed."
|
||||
|
|
Loading…
Reference in New Issue