forked from playframework/playframework
/
test-scripted
executable file
·56 lines (43 loc) · 2.78 KB
/
test-scripted
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Copyright (C) Lightbend Inc. <https://www.lightbend.com>
# shellcheck source=scripts/scriptLib
. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/scriptLib"
SBT_VERSION=$1
if [ -z $SBT_VERSION ]; then
echo "You need to pass the sbt version as first and the Scala version as second argument to this script"
exit 1
fi
shift
SCALA_VERSION=$1
if [ -z $SCALA_VERSION ]; then
echo "You need to pass the Scala version as second argument to this script"
exit 1
fi
shift
# Set the $SCALA_VERSION_SHELL variable.
# When running scripted tests with sbt 0.13.x we need to switch the sbt shell to Scala 2.10, otherwise we run into:
# java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;
# This happens when listing the scripted tests. I guess that is because sbt shell starts with 1.3.x by default
# (and therefore Scala 2.12), but later "set scriptedSbt := 0.13.18" requires Scala 2.10 which is not "loaded" (?)
# The scripted tests itself however will always be run with $SBT_VERSION and $SCALA_VERSION, they never see $SCALA_VERSION_SHELL
setShellScalaVersionFromSbtVersion
cd "$BASEDIR"
start scripted "RUNNING SCRIPTED TESTS FOR SBT $SBT_VERSION AND SCALA $SCALA_VERSION"
if [ "$TRAVIS" = "true" ]; then
# Make sure scripted tests run with the same git commit that was used for the publish-local job.
# For each CI job the CI server always clones the latest up-to-date base branch and, if the current job is for a pull request,
# then "fetches" the current pull request on top of it (just look at the logs of a PR job, you will see "git fetch origin +refs/pull/<#PR>/merge").
# Now if another pull request gets merged in the time window during the publish-local and a scripted job, the base branches moves forward
# and the CI server will now clone that newer base branch before "fetching" the current PR on it. Of course now the commit hash has changed and
# the distance from the latest tag has increased, so the Play version set by dynver will be different than the one used for publish-local, resulting
# in "unresolved dependencies" errors.
PUBLISHED_LOCAL_COMMIT_HASH=$(cat $HOME/.ivy2/local/com.typesafe.play/PUBLISHED_LOCAL_COMMIT_HASH)
git fetch origin ${PUBLISHED_LOCAL_COMMIT_HASH}
git checkout ${PUBLISHED_LOCAL_COMMIT_HASH}
echo "Checked out git commit ${PUBLISHED_LOCAL_COMMIT_HASH} which was used for publish-local in previous job"
# This is just for "debugging"
ls -alFhR ~/.ivy2 | grep play | grep jar
ls -alFhR ~/.cache/coursier | grep play | grep jar
fi
runSbt ";project Sbt-Plugin;set scriptedSbt := \"${SBT_VERSION}\";set scriptedLaunchOpts += \"-Dscala.version=${SCALA_VERSION}\";++$SCALA_VERSION_SHELL;show scriptedSbt;show scriptedLaunchOpts;scripted $@"
end scripted "ALL SCRIPTED TESTS PASSED"