|
1 |
| -#!/bin/sh |
| 1 | +#!/usr/bin/env bash |
2 | 2 |
|
3 |
| -cd "$(dirname "$0")" |
4 |
| -set -e |
| 3 | +set -o errexit; |
| 4 | +set -o nounset; |
5 | 5 |
|
| 6 | +#let the caller supply an ELM_TEST binary if desired |
| 7 | +if [ -z "${ELM_TEST:-}" ]; then |
| 8 | + ELM_TEST=elm-test; |
| 9 | +fi |
6 | 10 |
|
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. |
8 | 15 |
|
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" |
11 | 49 | CORE_GIT_DIR="$(dirname $PWD)"
|
12 | 50 |
|
| 51 | +echo; |
13 | 52 | 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 |
16 | 64 |
|
17 |
| -elm-make --yes --output test.js Main.elm |
| 65 | +echo; |
| 66 | +echo "running tests ..."; |
| 67 | +echo; |
18 | 68 |
|
19 |
| -elm-test Main.elm |
| 69 | +"${ELM_TEST}" tests/Main.elm; |
0 commit comments