Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
/pack/
/cli-test/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
- SCALAJS_VERSION=1.0.0
script:
- ./scripts/assemble-cli.sh $SCALAJS_VERSION $TRAVIS_SCALA_VERSION
- ./scripts/test-cli.sh $SCALAJS_VERSION $TRAVIS_SCALA_VERSION
cache:
directories:
- $HOME/.ivy2/cache
Expand Down
2 changes: 1 addition & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TODO: We should automate this process

For each major Scala version on a *NIX distro and a Windows distro:
For each major Scala version on a Windows distro:

1. Download packaged Scala from scala-lang.org
2. Build a CLI distribution (see [the release process](./RELEASING.md))
Expand Down
41 changes: 4 additions & 37 deletions scripts/assemble-cli.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
#! /bin/sh

set -e

# Assembles the CLI tools for a given Scala binary version.

if [ $# -lt 2 ]; then
echo "Usage: $(basename $0) <scala.js full version> <base scala full version>" >&2
exit 1
fi

SCALAJS_VER=$1

BASEVER=$2
case $BASEVER in
2.11.*)
BINVER="2.11"
;;
2.12.*)
BINVER="2.12"
;;
2.13.*)
BINVER="2.13"
;;
*)
echo "Invalid Scala version $BINVER" >&2
exit 2
esac
. "$(dirname $0)/vars.sh"

# Build and lay out the contents of the archives
sbt \
Expand All @@ -35,21 +12,11 @@ sbt \
"cliPack" \
|| exit $?

# Base Scala.js project directory.
BASE="$(dirname $0)/.."

# Aritfact name (no extension).
NAME=scalajs_$BINVER-$SCALAJS_VER

# Target directories
TRG_BASE="$BASE/pack"
TRG_VER="$TRG_BASE/$NAME"

# Tar and zip the whole thing up
(
cd $TRG_BASE
tar cfz $NAME.tgz $NAME
tar cfz $SJS_ARTIFACT_NAME.tgz $SJS_ARTIFACT_NAME

if [ -f $NAME.zip ]; then rm $NAME.zip; fi
zip -r $NAME.zip -r $NAME
if [ -f $SJS_ARTIFACT_NAME.zip ]; then rm $SJS_ARTIFACT_NAME.zip; fi
zip -r $SJS_ARTIFACT_NAME.zip -r $SJS_ARTIFACT_NAME
)
59 changes: 59 additions & 0 deletions scripts/test-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#! /bin/sh

# Tests the CLI tools.

. "$(dirname $0)/vars.sh"

TEST_DIR="$(realpath $(dirname $0)/../cli-test)"

rm -rf $TEST_DIR
mkdir $TEST_DIR
cd $TEST_DIR

# Fetch Scala
SCALA_ARTIFACT_NAME=scala-$BASEVER
wget "https://downloads.lightbend.com/scala/$BASEVER/$SCALA_ARTIFACT_NAME.tgz"
tar xf $SCALA_ARTIFACT_NAME.tgz

# Fetch Scala.js
cp $TRG_BASE/$SJS_ARTIFACT_NAME.tgz .
tar xf $SJS_ARTIFACT_NAME.tgz

# Setup PATH
PATH=$PATH:$TEST_DIR/$SCALA_ARTIFACT_NAME/bin:$TEST_DIR/$SJS_ARTIFACT_NAME/bin

fail() {
echo "$1" >&2
exit 2
}

# Actual test.
mkdir bin
cat > foo.scala <<'EOF'
object Foo {
def main(args: Array[String]): Unit = {
println(s"asdf ${1 + 1}")
new A
}

class A
}
EOF

scalajsc -d bin foo.scala

scalajsp bin/Foo$.sjsir > out
test -s out || fail "scalajsp bin/Foo$.sjsir: empty output"

scalajsp bin/Foo\$A.sjsir > out
test -s out || fail "scalajsp bin/Foo\$A.sjsir: empty output"

scalajsld -o test.js -mm Foo.main bin
test -s test.js || fail "scalajsld: empty output"

node test.js > got.run
cat > want.run <<EOF
asdf 2
EOF

diff got.run want.run
29 changes: 29 additions & 0 deletions scripts/vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
set -e

if [ $# -lt 2 ]; then
echo "Usage: $(basename $0) <scala.js full version> <base scala full version>" >&2
exit 1
fi

SCALAJS_VER=$1

BASEVER=$2
case $BASEVER in
2.11.*)
BINVER="2.11"
;;
2.12.*)
BINVER="2.12"
;;
2.13.*)
BINVER="2.13"
;;
*)
echo "Invalid Scala version $BINVER" >&2
exit 2
esac

# Base Scala.js project directory.
TRG_BASE="$(realpath $(dirname $0)/../pack)"

SJS_ARTIFACT_NAME=scalajs_$BINVER-$SCALAJS_VER
2 changes: 1 addition & 1 deletion src/main/resources/scalajsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SCALA_BIN_VER="@SCALA_BIN_VER@"
SCALAJS_VER="@SCALAJS_VER@"
SCALA_VER=$(scalac -version 2>&1 | grep -o '[0-9]\.[0-9]\+\.[0-9]\+')
SCALA_VER=$(scalac -version 2>&1 | grep -i scala | grep -o '[0-9]\.[0-9]\+\.[0-9]\+')

if [ "$(echo $SCALA_VER | cut -d '.' -f 1-2)" != "$SCALA_BIN_VER" ]; then
echo "This bundle of Scala.js CLI is for $SCALA_BIN_VER. Your scala version is $SCALA_VER!" >&2
Expand Down