From 556b9f428f79485e677bfed032e4ff2b959e9054 Mon Sep 17 00:00:00 2001 From: Matthieu Pizenberg Date: Mon, 5 Apr 2021 20:04:15 +0200 Subject: [PATCH 1/7] Alternative tests scripts based on a package --- core-tests/.gitignore | 1 + core-tests/elm.json | 18 +++++ core-tests/run-tests.sh | 38 ++++++++++ {tests => core-tests}/tests/Main.elm | 13 ++-- {tests => core-tests}/tests/Test/Array.elm | 0 {tests => core-tests}/tests/Test/Basics.elm | 0 {tests => core-tests}/tests/Test/Bitwise.elm | 0 {tests => core-tests}/tests/Test/Char.elm | 0 {tests => core-tests}/tests/Test/CodeGen.elm | 0 {tests => core-tests}/tests/Test/Dict.elm | 0 {tests => core-tests}/tests/Test/Equality.elm | 0 {tests => core-tests}/tests/Test/List.elm | 0 {tests => core-tests}/tests/Test/Maybe.elm | 0 {tests => core-tests}/tests/Test/Result.elm | 0 {tests => core-tests}/tests/Test/Set.elm | 0 {tests => core-tests}/tests/Test/String.elm | 0 {tests => core-tests}/tests/Test/Tuple.elm | 0 tests/elm.json | 26 ------- tests/run-tests.sh | 70 ------------------- 19 files changed, 61 insertions(+), 105 deletions(-) create mode 100644 core-tests/.gitignore create mode 100644 core-tests/elm.json create mode 100755 core-tests/run-tests.sh rename {tests => core-tests}/tests/Main.elm (71%) rename {tests => core-tests}/tests/Test/Array.elm (100%) rename {tests => core-tests}/tests/Test/Basics.elm (100%) rename {tests => core-tests}/tests/Test/Bitwise.elm (100%) rename {tests => core-tests}/tests/Test/Char.elm (100%) rename {tests => core-tests}/tests/Test/CodeGen.elm (100%) rename {tests => core-tests}/tests/Test/Dict.elm (100%) rename {tests => core-tests}/tests/Test/Equality.elm (100%) rename {tests => core-tests}/tests/Test/List.elm (100%) rename {tests => core-tests}/tests/Test/Maybe.elm (100%) rename {tests => core-tests}/tests/Test/Result.elm (100%) rename {tests => core-tests}/tests/Test/Set.elm (100%) rename {tests => core-tests}/tests/Test/String.elm (100%) rename {tests => core-tests}/tests/Test/Tuple.elm (100%) delete mode 100644 tests/elm.json delete mode 100755 tests/run-tests.sh diff --git a/core-tests/.gitignore b/core-tests/.gitignore new file mode 100644 index 00000000..cbb16464 --- /dev/null +++ b/core-tests/.gitignore @@ -0,0 +1 @@ +.elm diff --git a/core-tests/elm.json b/core-tests/elm.json new file mode 100644 index 00000000..dc635d4e --- /dev/null +++ b/core-tests/elm.json @@ -0,0 +1,18 @@ +{ + "type": "package", + "name": "elm/core-tests", + "summary": "Elm's standard libraries", + "license": "BSD-3-Clause", + "version": "1.0.5", + "elm-version": "0.19.0 <= v < 0.20.0", + "exposed-modules": [ + "EmptyPlaceholderModule" + ], + "dependencies": { + "elm/core": "1.0.0 <= v < 2.0.0" + }, + "test-dependencies": { + "elm/json": "1.1.3 <= v < 2.0.0", + "elm-explorations/test": "1.2.2 <= v < 2.0.0" + } +} diff --git a/core-tests/run-tests.sh b/core-tests/run-tests.sh new file mode 100755 index 00000000..6ff10ccc --- /dev/null +++ b/core-tests/run-tests.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -o errexit; +set -o nounset; + +# Let the caller supply an ELM_TEST binary if desired. +if [ -z "${ELM_TEST:-}" ]; then + ELM_TEST=elm-test; +fi + +# Since elm/core is treated specially by the compiler (it's always +# inserted as a dependency even when not declared explicitly), we use +# a bit of a hack to make the tests run against the local source code +# rather than the elm/core source fetched from package.elm-lang.org. + +# Create a local directory where the compiler will look for the +# elm/core source code: + +export ELM_HOME="$PWD/.elm"; +rm -rf "$ELM_HOME" && mkdir -p "$ELM_HOME"; +rm -rf elm-stuff; + +# Create a link to the git package +CORE_LINK="${ELM_HOME}/0.19.1/packages/elm/core/1.0.5" +CORE_GIT_DIR="$(dirname $PWD)" +echo; +echo "Linking $CORE_LINK to $CORE_GIT_DIR" +echo; +mkdir -p "$(dirname $CORE_LINK)" +ln -sv "${CORE_LINK}" "${CORE_GIT_DIR}" +rm -vf "${CORE_GIT_DIR}"/*.dat "${CORE_GIT_DIR}"/doc*.json + +# Now we can run the tests against the symlinked source code for real. +echo; +echo "running tests ..."; +echo; + +"${ELM_TEST}" "$@"; diff --git a/tests/tests/Main.elm b/core-tests/tests/Main.elm similarity index 71% rename from tests/tests/Main.elm rename to core-tests/tests/Main.elm index 51bef482..86378ae6 100644 --- a/tests/tests/Main.elm +++ b/core-tests/tests/Main.elm @@ -1,20 +1,15 @@ -module Main exposing (..) +module Main exposing (tests) -import Basics exposing (..) -import Task exposing (..) -import Test exposing (..) -import Platform.Cmd exposing (Cmd) -import Json.Decode exposing (Value) -import Test.Runner.Node exposing (run, TestProgram) +import Test exposing (Test) import Test.Array as Array import Test.Basics as Basics import Test.Bitwise as Bitwise import Test.Char as Char import Test.CodeGen as CodeGen import Test.Dict as Dict -import Test.Maybe as Maybe import Test.Equality as Equality import Test.List as List +import Test.Maybe as Maybe import Test.Result as Result import Test.Set as Set import Test.String as String @@ -23,7 +18,7 @@ import Test.Tuple as Tuple tests : Test tests = - describe "Elm Standard Library Tests" + Test.describe "Elm Standard Library Tests" [ Array.tests , Basics.tests , Bitwise.tests diff --git a/tests/tests/Test/Array.elm b/core-tests/tests/Test/Array.elm similarity index 100% rename from tests/tests/Test/Array.elm rename to core-tests/tests/Test/Array.elm diff --git a/tests/tests/Test/Basics.elm b/core-tests/tests/Test/Basics.elm similarity index 100% rename from tests/tests/Test/Basics.elm rename to core-tests/tests/Test/Basics.elm diff --git a/tests/tests/Test/Bitwise.elm b/core-tests/tests/Test/Bitwise.elm similarity index 100% rename from tests/tests/Test/Bitwise.elm rename to core-tests/tests/Test/Bitwise.elm diff --git a/tests/tests/Test/Char.elm b/core-tests/tests/Test/Char.elm similarity index 100% rename from tests/tests/Test/Char.elm rename to core-tests/tests/Test/Char.elm diff --git a/tests/tests/Test/CodeGen.elm b/core-tests/tests/Test/CodeGen.elm similarity index 100% rename from tests/tests/Test/CodeGen.elm rename to core-tests/tests/Test/CodeGen.elm diff --git a/tests/tests/Test/Dict.elm b/core-tests/tests/Test/Dict.elm similarity index 100% rename from tests/tests/Test/Dict.elm rename to core-tests/tests/Test/Dict.elm diff --git a/tests/tests/Test/Equality.elm b/core-tests/tests/Test/Equality.elm similarity index 100% rename from tests/tests/Test/Equality.elm rename to core-tests/tests/Test/Equality.elm diff --git a/tests/tests/Test/List.elm b/core-tests/tests/Test/List.elm similarity index 100% rename from tests/tests/Test/List.elm rename to core-tests/tests/Test/List.elm diff --git a/tests/tests/Test/Maybe.elm b/core-tests/tests/Test/Maybe.elm similarity index 100% rename from tests/tests/Test/Maybe.elm rename to core-tests/tests/Test/Maybe.elm diff --git a/tests/tests/Test/Result.elm b/core-tests/tests/Test/Result.elm similarity index 100% rename from tests/tests/Test/Result.elm rename to core-tests/tests/Test/Result.elm diff --git a/tests/tests/Test/Set.elm b/core-tests/tests/Test/Set.elm similarity index 100% rename from tests/tests/Test/Set.elm rename to core-tests/tests/Test/Set.elm diff --git a/tests/tests/Test/String.elm b/core-tests/tests/Test/String.elm similarity index 100% rename from tests/tests/Test/String.elm rename to core-tests/tests/Test/String.elm diff --git a/tests/tests/Test/Tuple.elm b/core-tests/tests/Test/Tuple.elm similarity index 100% rename from tests/tests/Test/Tuple.elm rename to core-tests/tests/Test/Tuple.elm diff --git a/tests/elm.json b/tests/elm.json deleted file mode 100644 index 3c64414c..00000000 --- a/tests/elm.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "application", - "source-directories": [], - "elm-version": "0.19.1", - "dependencies": { - "direct": { - "elm/browser": "1.0.1", - "elm/core": "1.0.2", - "elm/html": "1.0.0" - }, - "indirect": { - "elm/json": "1.1.2", - "elm/time": "1.0.0", - "elm/url": "1.0.0", - "elm/virtual-dom": "1.0.2" - } - }, - "test-dependencies": { - "direct": { - "elm-explorations/test": "1.2.1" - }, - "indirect": { - "elm/random": "1.0.0" - } - } -} diff --git a/tests/run-tests.sh b/tests/run-tests.sh deleted file mode 100755 index b00aaa6e..00000000 --- a/tests/run-tests.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit; -set -o nounset; - -#let the caller supply an ELM_TEST binary if desired -if [ -z "${ELM_TEST:-}" ]; then - ELM_TEST=elm-test; -fi - -# since elm/core is treated specially by the compiler (it's always -# inserted as a dependency even when not declared explicitly), we use -# a bit of a hack to make the tests run against the local source code -# rather than the elm/core source fetched from package.elm-lang.org. - -# create a local directory where the compiler will look for the -# elm/core source code: - -DIR="$(dirname $0)"; - -cd "$DIR"; - -export ELM_HOME="$(pwd)/.elm"; - -rm -rf "$ELM_HOME" && mkdir -p "$ELM_HOME"; - -# elm-test also puts some things in elm-stuff, start with a clean -# slate there as well - -rm -rf elm-stuff; - -# now make an initial run of the tests to populate .elm and elm-stuff; -# this will test against elm/core from package.elm-lang.org, so we -# don't really care what the results are; we just need to force all -# the *other* dependencies to be fetched and set up. - -echo "seeding framework for test dependencies ..."; - -# '|| true' lets us ignore failures here and keep the script running. -# useful when developing a fix for a bug that exists in the version of -# elm/core hosted on package.elm-lang.org -"${ELM_TEST}" tests/Main.elm --fuzz=1 > /dev/null || true; - -# clear out the copy of elm-core fetched by the above and replace it -# with the local source code we want to actually test - -VERSION_DIR="$(ls ${ELM_HOME}/0.19.1/packages/elm/core/)" -CORE_PACKAGE_DIR="${ELM_HOME}/0.19.1/packages/elm/core/$VERSION_DIR" -CORE_GIT_DIR="$(dirname $PWD)" - -echo; -echo "Linking $CORE_PACKAGE_DIR to $CORE_GIT_DIR" -echo; - -rm -rf "$CORE_PACKAGE_DIR" -ln -sv "$CORE_GIT_DIR" "$CORE_PACKAGE_DIR" -rm -vf "${CORE_GIT_DIR}"/*.dat "${CORE_GIT_DIR}"/doc*.json - -# we also need to clear out elm-test's elm-stuff dir, since otherwise -# the compiler complains that its .dat files are out of sync - -rm -rf elm-stuff; - -# now we can run the tests against the symlinked source code for real - -echo; -echo "running tests ..."; -echo; - -"${ELM_TEST}" tests/Main.elm "$@"; From e5bb361f284465b3eeea048b347f732975d608e9 Mon Sep 17 00:00:00 2001 From: Matthieu Pizenberg Date: Mon, 5 Apr 2021 20:23:12 +0200 Subject: [PATCH 2/7] Fix script --- core-tests/run-tests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-tests/run-tests.sh b/core-tests/run-tests.sh index 6ff10ccc..f67b818f 100755 --- a/core-tests/run-tests.sh +++ b/core-tests/run-tests.sh @@ -27,10 +27,11 @@ echo; echo "Linking $CORE_LINK to $CORE_GIT_DIR" echo; mkdir -p "$(dirname $CORE_LINK)" -ln -sv "${CORE_LINK}" "${CORE_GIT_DIR}" +ln -sv "${CORE_GIT_DIR}" "${CORE_LINK}" rm -vf "${CORE_GIT_DIR}"/*.dat "${CORE_GIT_DIR}"/doc*.json # Now we can run the tests against the symlinked source code for real. +mkdir -p src/ # needed for compilation echo; echo "running tests ..."; echo; From 5ced15611be98d78d58abea4cd1c31b91bde18fd Mon Sep 17 00:00:00 2001 From: Harry Sarson Date: Fri, 16 Apr 2021 22:02:30 +0100 Subject: [PATCH 3/7] have git track the empty src dir in tests --- core-tests/run-tests.sh | 2 +- core-tests/src/empty | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 core-tests/src/empty diff --git a/core-tests/run-tests.sh b/core-tests/run-tests.sh index f67b818f..51194fb6 100755 --- a/core-tests/run-tests.sh +++ b/core-tests/run-tests.sh @@ -31,7 +31,7 @@ ln -sv "${CORE_GIT_DIR}" "${CORE_LINK}" rm -vf "${CORE_GIT_DIR}"/*.dat "${CORE_GIT_DIR}"/doc*.json # Now we can run the tests against the symlinked source code for real. -mkdir -p src/ # needed for compilation + echo; echo "running tests ..."; echo; diff --git a/core-tests/src/empty b/core-tests/src/empty new file mode 100644 index 00000000..e69de29b From b3a37f7a3426008272a748cd7b99682fa5c1df22 Mon Sep 17 00:00:00 2001 From: Harry Sarson Date: Sat, 24 Apr 2021 12:54:56 +0100 Subject: [PATCH 4/7] undo change to test location --- {core-tests => tests}/.gitignore | 0 {core-tests => tests}/elm.json | 0 {core-tests => tests}/run-tests.sh | 0 {core-tests => tests}/src/empty | 0 {core-tests => tests}/tests/Main.elm | 0 {core-tests => tests}/tests/Test/Array.elm | 0 {core-tests => tests}/tests/Test/Basics.elm | 0 {core-tests => tests}/tests/Test/Bitwise.elm | 0 {core-tests => tests}/tests/Test/Char.elm | 0 {core-tests => tests}/tests/Test/CodeGen.elm | 0 {core-tests => tests}/tests/Test/Dict.elm | 0 {core-tests => tests}/tests/Test/Equality.elm | 0 {core-tests => tests}/tests/Test/List.elm | 0 {core-tests => tests}/tests/Test/Maybe.elm | 0 {core-tests => tests}/tests/Test/Result.elm | 0 {core-tests => tests}/tests/Test/Set.elm | 0 {core-tests => tests}/tests/Test/String.elm | 0 {core-tests => tests}/tests/Test/Tuple.elm | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename {core-tests => tests}/.gitignore (100%) rename {core-tests => tests}/elm.json (100%) rename {core-tests => tests}/run-tests.sh (100%) rename {core-tests => tests}/src/empty (100%) rename {core-tests => tests}/tests/Main.elm (100%) rename {core-tests => tests}/tests/Test/Array.elm (100%) rename {core-tests => tests}/tests/Test/Basics.elm (100%) rename {core-tests => tests}/tests/Test/Bitwise.elm (100%) rename {core-tests => tests}/tests/Test/Char.elm (100%) rename {core-tests => tests}/tests/Test/CodeGen.elm (100%) rename {core-tests => tests}/tests/Test/Dict.elm (100%) rename {core-tests => tests}/tests/Test/Equality.elm (100%) rename {core-tests => tests}/tests/Test/List.elm (100%) rename {core-tests => tests}/tests/Test/Maybe.elm (100%) rename {core-tests => tests}/tests/Test/Result.elm (100%) rename {core-tests => tests}/tests/Test/Set.elm (100%) rename {core-tests => tests}/tests/Test/String.elm (100%) rename {core-tests => tests}/tests/Test/Tuple.elm (100%) diff --git a/core-tests/.gitignore b/tests/.gitignore similarity index 100% rename from core-tests/.gitignore rename to tests/.gitignore diff --git a/core-tests/elm.json b/tests/elm.json similarity index 100% rename from core-tests/elm.json rename to tests/elm.json diff --git a/core-tests/run-tests.sh b/tests/run-tests.sh similarity index 100% rename from core-tests/run-tests.sh rename to tests/run-tests.sh diff --git a/core-tests/src/empty b/tests/src/empty similarity index 100% rename from core-tests/src/empty rename to tests/src/empty diff --git a/core-tests/tests/Main.elm b/tests/tests/Main.elm similarity index 100% rename from core-tests/tests/Main.elm rename to tests/tests/Main.elm diff --git a/core-tests/tests/Test/Array.elm b/tests/tests/Test/Array.elm similarity index 100% rename from core-tests/tests/Test/Array.elm rename to tests/tests/Test/Array.elm diff --git a/core-tests/tests/Test/Basics.elm b/tests/tests/Test/Basics.elm similarity index 100% rename from core-tests/tests/Test/Basics.elm rename to tests/tests/Test/Basics.elm diff --git a/core-tests/tests/Test/Bitwise.elm b/tests/tests/Test/Bitwise.elm similarity index 100% rename from core-tests/tests/Test/Bitwise.elm rename to tests/tests/Test/Bitwise.elm diff --git a/core-tests/tests/Test/Char.elm b/tests/tests/Test/Char.elm similarity index 100% rename from core-tests/tests/Test/Char.elm rename to tests/tests/Test/Char.elm diff --git a/core-tests/tests/Test/CodeGen.elm b/tests/tests/Test/CodeGen.elm similarity index 100% rename from core-tests/tests/Test/CodeGen.elm rename to tests/tests/Test/CodeGen.elm diff --git a/core-tests/tests/Test/Dict.elm b/tests/tests/Test/Dict.elm similarity index 100% rename from core-tests/tests/Test/Dict.elm rename to tests/tests/Test/Dict.elm diff --git a/core-tests/tests/Test/Equality.elm b/tests/tests/Test/Equality.elm similarity index 100% rename from core-tests/tests/Test/Equality.elm rename to tests/tests/Test/Equality.elm diff --git a/core-tests/tests/Test/List.elm b/tests/tests/Test/List.elm similarity index 100% rename from core-tests/tests/Test/List.elm rename to tests/tests/Test/List.elm diff --git a/core-tests/tests/Test/Maybe.elm b/tests/tests/Test/Maybe.elm similarity index 100% rename from core-tests/tests/Test/Maybe.elm rename to tests/tests/Test/Maybe.elm diff --git a/core-tests/tests/Test/Result.elm b/tests/tests/Test/Result.elm similarity index 100% rename from core-tests/tests/Test/Result.elm rename to tests/tests/Test/Result.elm diff --git a/core-tests/tests/Test/Set.elm b/tests/tests/Test/Set.elm similarity index 100% rename from core-tests/tests/Test/Set.elm rename to tests/tests/Test/Set.elm diff --git a/core-tests/tests/Test/String.elm b/tests/tests/Test/String.elm similarity index 100% rename from core-tests/tests/Test/String.elm rename to tests/tests/Test/String.elm diff --git a/core-tests/tests/Test/Tuple.elm b/tests/tests/Test/Tuple.elm similarity index 100% rename from core-tests/tests/Test/Tuple.elm rename to tests/tests/Test/Tuple.elm From 05a5839fb77c5d645c00f37bfc176ae5e6c9da4b Mon Sep 17 00:00:00 2001 From: Harry Sarson Date: Sat, 24 Apr 2021 12:56:53 +0100 Subject: [PATCH 5/7] re-add the changedir logic --- tests/run-tests.sh | 4 ++++ 1 file changed, 4 insertions(+) mode change 100755 => 100644 tests/run-tests.sh diff --git a/tests/run-tests.sh b/tests/run-tests.sh old mode 100755 new mode 100644 index 51194fb6..d6de6142 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -16,6 +16,10 @@ fi # Create a local directory where the compiler will look for the # elm/core source code: +DIR="$(dirname $0)"; + +cd "$DIR"; + export ELM_HOME="$PWD/.elm"; rm -rf "$ELM_HOME" && mkdir -p "$ELM_HOME"; rm -rf elm-stuff; From b65fc2f43029bb6f21c3db36a14a6dd8b156dba3 Mon Sep 17 00:00:00 2001 From: Harry Sarson Date: Sat, 24 Apr 2021 13:13:08 +0100 Subject: [PATCH 6/7] do not run every test twice! --- tests/run-tests.sh | 0 tests/tests/Main.elm | 35 ----------------------------------- 2 files changed, 35 deletions(-) mode change 100644 => 100755 tests/run-tests.sh delete mode 100644 tests/tests/Main.elm diff --git a/tests/run-tests.sh b/tests/run-tests.sh old mode 100644 new mode 100755 diff --git a/tests/tests/Main.elm b/tests/tests/Main.elm deleted file mode 100644 index 86378ae6..00000000 --- a/tests/tests/Main.elm +++ /dev/null @@ -1,35 +0,0 @@ -module Main exposing (tests) - -import Test exposing (Test) -import Test.Array as Array -import Test.Basics as Basics -import Test.Bitwise as Bitwise -import Test.Char as Char -import Test.CodeGen as CodeGen -import Test.Dict as Dict -import Test.Equality as Equality -import Test.List as List -import Test.Maybe as Maybe -import Test.Result as Result -import Test.Set as Set -import Test.String as String -import Test.Tuple as Tuple - - -tests : Test -tests = - Test.describe "Elm Standard Library Tests" - [ Array.tests - , Basics.tests - , Bitwise.tests - , Char.tests - , CodeGen.tests - , Dict.tests - , Equality.tests - , List.tests - , Result.tests - , Set.tests - , String.tests - , Maybe.tests - , Tuple.tests - ] From a888bfedfddd7d505808d017e8e6519017c65dfd Mon Sep 17 00:00:00 2001 From: Harry Sarson Date: Sat, 24 Apr 2021 14:33:46 +0100 Subject: [PATCH 7/7] read elm-core version from json before symlinking --- tests/run-tests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index d6de6142..b1c7f5cd 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -25,7 +25,8 @@ rm -rf "$ELM_HOME" && mkdir -p "$ELM_HOME"; rm -rf elm-stuff; # Create a link to the git package -CORE_LINK="${ELM_HOME}/0.19.1/packages/elm/core/1.0.5" +VERSION=$(node -e "console.log(require('../elm.json').version)") +CORE_LINK="${ELM_HOME}/0.19.1/packages/elm/core/${VERSION}" CORE_GIT_DIR="$(dirname $PWD)" echo; echo "Linking $CORE_LINK to $CORE_GIT_DIR"