Skip to content

Commit e2b18de

Browse files
authored
Merge pull request #1017 from jerith666/fix-tests
update run-tests.sh to work with 0.19
2 parents 5dcec7f + 48283ae commit e2b18de

19 files changed

+92
-60
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
elm-stuff
22
tests/test.js
3-
node_modules/
3+
node_modules/
4+
*.dat
5+
doc*.json
6+
tests/.elm
7+
*~

.travis.yml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,4 @@
1-
sudo: false
2-
3-
cache:
4-
directories:
5-
- test/elm-stuff/build-artifacts
6-
- sysconfcpus
7-
8-
language: node_js
9-
10-
node_js:
11-
- "4.3"
12-
13-
before_install:
14-
- if [ ${TRAVIS_OS_NAME} == "osx" ];
15-
then brew update; brew install nvm; mkdir ~/.nvm; export NVM_DIR=~/.nvm; source $(brew --prefix nvm)/nvm.sh;
16-
fi
17-
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
18-
- | # epic build time improvement - see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142
19-
if [ ! -d sysconfcpus/bin ];
20-
then
21-
git clone https://github.com/obmarg/libsysconfcpus.git;
22-
cd libsysconfcpus;
23-
./configure --prefix=$TRAVIS_BUILD_DIR/sysconfcpus;
24-
make && make install;
25-
cd ..;
26-
fi
27-
28-
install:
29-
- npm install -g [email protected] elm-test
30-
- mv $(npm config get prefix)/bin/elm-make $(npm config get prefix)/bin/elm-make-old
31-
- printf '%s\n\n' '#!/bin/bash' 'echo "Running elm-make with sysconfcpus -n 2"' '$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-make-old "$@"' > $(npm config get prefix)/bin/elm-make
32-
- chmod +x $(npm config get prefix)/bin/elm-make
1+
language: elm
332

343
script:
354
- bash tests/run-tests.sh

tests/elm-package.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/elm.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"type": "application",
3+
"source-directories": [],
4+
"elm-version": "0.19.0",
5+
"dependencies": {
6+
"direct": {
7+
"elm/browser": "1.0.1",
8+
"elm/core": "1.0.2",
9+
"elm/html": "1.0.0"
10+
},
11+
"indirect": {
12+
"elm/json": "1.1.2",
13+
"elm/time": "1.0.0",
14+
"elm/url": "1.0.0",
15+
"elm/virtual-dom": "1.0.2"
16+
}
17+
},
18+
"test-dependencies": {
19+
"direct": {
20+
"elm-explorations/test": "1.2.1"
21+
},
22+
"indirect": {
23+
"elm/random": "1.0.0"
24+
}
25+
}
26+
}

tests/run-tests.sh

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,69 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

3-
cd "$(dirname "$0")"
4-
set -e
3+
set -o errexit;
4+
set -o nounset;
55

6+
#let the caller supply an ELM_TEST binary if desired
7+
if [ -z "${ELM_TEST:-}" ]; then
8+
ELM_TEST=elm-test;
9+
fi
610

7-
elm-package install -y
11+
# since elm/core is treated specially by the compiler (it's always
12+
# inserted as a dependency even when not declared explicitly), we use
13+
# a bit of a hack to make the tests run against the local source code
14+
# rather than the elm/core source fetched from package.elm-lang.org.
815

9-
VERSION_DIR="$(ls elm-stuff/packages/elm-lang/core/)"
10-
CORE_PACKAGE_DIR="elm-stuff/packages/elm-lang/core/$VERSION_DIR"
16+
# create a local directory where the compiler will look for the
17+
# elm/core source code:
18+
19+
DIR="$(dirname $0)";
20+
21+
cd "$DIR";
22+
23+
export ELM_HOME="$(pwd)/.elm";
24+
25+
rm -rf "$ELM_HOME" && mkdir -p "$ELM_HOME";
26+
27+
# elm-test also puts some things in elm-stuff, start with a clean
28+
# slate there as well
29+
30+
rm -rf elm-stuff;
31+
32+
# now make an initial run of the tests to populate .elm and elm-stuff;
33+
# this will test against elm/core from package.elm-lang.org, so we
34+
# don't really care what the results are; we just need to force all
35+
# the *other* dependencies to be fetched and set up.
36+
37+
echo "seeding framework for test dependencies ...";
38+
39+
# '|| true' lets us ignore failures here and keep the script running.
40+
# useful when developing a fix for a bug that exists in the version of
41+
# elm/core hosted on package.elm-lang.org
42+
"${ELM_TEST}" tests/Main.elm > /dev/null || true;
43+
44+
# clear out the copy of elm-core fetched by the above and replace it
45+
# with the local source code we want to actually test
46+
47+
VERSION_DIR="$(ls ${ELM_HOME}/0.19.0/package/elm/core/)"
48+
CORE_PACKAGE_DIR="${ELM_HOME}/0.19.0/package/elm/core/$VERSION_DIR"
1149
CORE_GIT_DIR="$(dirname $PWD)"
1250

51+
echo;
1352
echo "Linking $CORE_PACKAGE_DIR to $CORE_GIT_DIR"
14-
rm -rf $CORE_PACKAGE_DIR
15-
ln -s $CORE_GIT_DIR $CORE_PACKAGE_DIR
53+
echo;
54+
rm -rf "$CORE_PACKAGE_DIR"
55+
ln -sv "$CORE_GIT_DIR" "$CORE_PACKAGE_DIR"
56+
rm -vf "${CORE_GIT_DIR}"/*.dat "${CORE_GIT_DIR}"/doc*.json
57+
58+
# we also need to clear out elm-test's elm-stuff dir, since otherwise
59+
# the compiler complains that its .dat files are out of sync
60+
61+
rm -rf elm-stuff;
62+
63+
# now we can run the tests against the symlinked source code for real
1664

17-
elm-make --yes --output test.js Main.elm
65+
echo;
66+
echo "running tests ...";
67+
echo;
1868

19-
elm-test Main.elm
69+
"${ELM_TEST}" tests/Main.elm;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)