Unverified Commit 83cf5580 authored by Austin Blatt's avatar Austin Blatt Committed by GitHub

Merge pull request #2790 from austb/tmp/jdk-info

(PDB-4246) travis: add check-spec-env test
parents e8077d11 fe62b75a
......@@ -22,7 +22,7 @@ services:
aliases:
- &run-core-and-ext-tests |
set -e
jdk="$(ext/travisci/jdk-from-spec "$PDB_TEST")"
jdk="$(ext/bin/jdk-from-spec "$PDB_TEST")"
jdkver="${jdk##*jdk}"
ext/travisci/prep-os-essentials-for "$PDB_TEST"
case "$OSTYPE" in
......@@ -46,12 +46,13 @@ aliases:
pgver="$(ext/travisci/prefixed-ref-from-spec "$PDB_TEST" pg-)"
ext/bin/test-config --set pgver "$pgver"
ext/bin/test-config --set pgport 34335
ext/bin/check-spec-env "$PDB_TEST"
ext/bin/boxed-core-tests -- lein test
ext/bin/run-external-tests
- &run-integration-tests |
set -e
jdk="$(ext/travisci/jdk-from-spec "$PDB_TEST")"
jdk="$(ext/bin/jdk-from-spec "$PDB_TEST")"
jdkver="${jdk##*jdk}"
ext/travisci/prep-os-essentials-for "$PDB_TEST"
case "$OSTYPE" in
......@@ -79,11 +80,13 @@ aliases:
ext/bin/test-config --set pgport 34335
ext/bin/test-config --set puppet-ref "$puppet"
ext/bin/test-config --set puppetserver-ref "$server"
ext/bin/check-spec-env "$PDB_TEST"
ext/bin/boxed-integration-tests -- lein test :integration
- &run-spec-tests |
set -e
puppet_ref="$(ext/travisci/prefixed-ref-from-spec "$PDB_TEST" pup-)"
ext/bin/check-spec-env "$PDB_TEST"
ext/bin/run-rspec-tests "$puppet_ref"
- &run-docker-tests |
......
#!/usr/bin/env bash
set -ueo pipefail
usage()
{
echo "Usage: $(basename $0) SPEC"
}
misuse()
{
usage 1>&2
exit 2
}
verify-jdk() {
local spec="$1"
echo spec: [$spec]
local actual_jdk expected_jdk
expected_jdk="$(ext/bin/jdk-from-spec "$spec")"
actual_jdk="$(ext/bin/jdk-info --print spec)"
if test "$expected_jdk" != "$actual_jdk"; then
printf "JDK in path %q is not what PDB_TEST specifies: %q\n" \
"$actual_jdk" "$expected_jdk" 1>&2
exit 2
fi
}
test $# -ne 1 && misuse
spec="$1"
test_kind=''
for item in ${spec//// }; do # change / to ' '
echo item: "[$item]"
case "$item" in
core+ext|int|rspec) test_kind="$item" ;;
esac
done
if test -z "$test_kind"; then
echo "Unable to find a test category in $spec" 1>&2
exit 2
fi
case "$test_kind" in
core+ext|int)
verify-jdk "$spec"
;;
rspec)
;;
*)
echo "Unexpected test category: $test_kind" 1>&2
exit 2
;;
esac
#!/usr/bin/env bash
set -ueo pipefail
usage()
{
echo "Usage: $(basename $0) <--print (version|major|spec)>..."
}
misuse()
{
usage 1>&2
exit 2
}
extract-major() {
local ver="$1"
local ver_x="${ver%%.*}"
if test "$ver_x" -ge 10; then
echo "$ver_x"
else
echo "$ver" | sed -E 's/[0-9]+\.([0-9]+).*/\1/'
fi
}
print-info() {
local what="$1"
local ver ver_out
# java -version prints the requested info to stderr...
ver_out=$(java -version 2>&1 1>/dev/null)
# Looks like the third field of the first line always has a
# quoted version string. Some variants:
# java version "1.8.0_172"
# openjdk version "1.8.0_171"
# openjdk version "10.0.2" 2018-07-17
# openjdk version "10.0.2-adoptopenjdk" 2018-07-17
ver=$(echo "$ver_out" | head -1 | cut -d' ' -f 3 | sed -E 's/^"(.+)"$/\1/')
case "$what" in
version) echo "$ver" ;;
major) echo "$(extract-major "$ver")" ;;
spec)
local maj_ver
maj_ver=$(extract-major "$ver")
if echo "$ver_out" | grep -qiF openjdk; then
echo "openjdk$maj_ver"
else
echo "oraclejdk$maj_ver"
fi
;;
*) misuse ;;
esac
}
if test $# -eq 0; then
misuse
fi
while test $# -gt 0; do
case "$1" in
--print)
shift
test $# -gt 0 || misuse
what="$1"
shift
case "$what" in
version|major|spec)
print-info "$what"
;;
*) misuse ;;
esac
;;
*)
misuse
esac
done
......@@ -14,7 +14,7 @@ misuse() {
test $# -eq 1 || misuse
spec="$1"
jdk="$(ext/travisci/jdk-from-spec "$spec")"
jdk="$(ext/bin/jdk-from-spec "$spec")"
jdkver="${jdk##*jdk}"
pgver="$(ext/travisci/prefixed-ref-from-spec "$spec" pg-)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment