diff --git a/bin/run-tests.sh b/bin/run-tests.sh index 41bd84d..ae2146e 100755 --- a/bin/run-tests.sh +++ b/bin/run-tests.sh @@ -18,19 +18,16 @@ for test_dir in tests/*/*; do test_dir_name=$(basename "${test_dir}") test_dir_path=$(realpath "${test_dir}") slug="identity" - - bin/run.sh "${slug}" "${test_dir_path}/" "${test_dir_path}/" - file="results.json" expected_file="expected_${file}" - tmp_results_file=$(mktemp -t results.json) - tmp_expected_results_file=$(mktemp -t expected_results.json) - jq '.' "${test_dir_path}/${file}" > "${tmp_results_file}" - jq '.' "${test_dir_path}/${expected_file}" > "${tmp_expected_results_file}" + bin/run.sh "${slug}" "${test_dir_path}/" "${test_dir_path}/" + + # Normalize the generated results.json file to make it easier to diff + jq '.' "${test_dir_path}/${file}" > tmp && mv tmp "${test_dir_path}/${file}" echo "${test_dir_name}: comparing ${file} to ${expected_file}" - if ! diff "${tmp_results_file}" "${tmp_expected_results_file}"; then + if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then exit_code=1 fi done diff --git a/tests/error/compiletime_error_closing_quote_expected/expected_results.json b/tests/error/compiletime_error_closing_quote_expected/expected_results.json index 12a08e2..bb3ecae 100644 --- a/tests/error/compiletime_error_closing_quote_expected/expected_results.json +++ b/tests/error/compiletime_error_closing_quote_expected/expected_results.json @@ -1,6 +1,6 @@ { "version": 2, "status": "error", - "message": "\u001b[1mhello_world.nim(2, 3) \u001b[0m\u001b[31mError: \u001b[0mclosing \" expected\u001b[36m\u001b[0m\u001b[0m\n", + "message": "\u001b[1midentity.nim(2, 3) \u001b[0m\u001b[31mError: \u001b[0mclosing \" expected\u001b[36m\u001b[0m\u001b[0m\n", "tests": [] } diff --git a/tests/error/compiletime_error_closing_quote_expected/hello_world.nim b/tests/error/compiletime_error_closing_quote_expected/identity.nim similarity index 100% rename from tests/error/compiletime_error_closing_quote_expected/hello_world.nim rename to tests/error/compiletime_error_closing_quote_expected/identity.nim diff --git a/tests/error/compiletime_error_closing_quote_expected/test_hello_world.nim b/tests/error/compiletime_error_closing_quote_expected/test_identity.nim similarity index 85% rename from tests/error/compiletime_error_closing_quote_expected/test_hello_world.nim rename to tests/error/compiletime_error_closing_quote_expected/test_identity.nim index f0bfcb0..878a499 100644 --- a/tests/error/compiletime_error_closing_quote_expected/test_hello_world.nim +++ b/tests/error/compiletime_error_closing_quote_expected/test_identity.nim @@ -1,5 +1,5 @@ import std/unittest -import hello_world +import identity # version 1.1.0 diff --git a/tests/pass/single_test/expected_results.json b/tests/pass/single_test/expected_results.json index 1d9fe4b..c12457f 100644 --- a/tests/pass/single_test/expected_results.json +++ b/tests/pass/single_test/expected_results.json @@ -3,10 +3,10 @@ "status": "pass", "tests": [ { - "name": "say hi!", + "name": "identity function of 1", "status": "pass", "output": "", - "test_code": "check hello() == \"Hello, World!\"" + "test_code": "check identity(1) == 1" } ] } diff --git a/tests/pass/single_test/expected_test_hello_world_prepared.nim b/tests/pass/single_test/expected_test_hello_world_prepared.nim deleted file mode 100644 index a046fd1..0000000 --- a/tests/pass/single_test/expected_test_hello_world_prepared.nim +++ /dev/null @@ -1,20 +0,0 @@ -import std/streams -import unittest_json -import std/unittest -import hello_world - -# version 1.1.0 - -var strm = newFileStream("trunner_replaces_this_with_path_to_results_json", fmWrite) -let formatter = newJsonOutputFormatter(strm) -addOutputFormatter(formatter) - -template test(name, body: untyped) {.dirty.} = - testWrapper name: - body - -suite "Hello World": - test "say hi!": - check hello() == "Hello, World!" - -close(formatter) diff --git a/tests/pass/single_test/hello_world.nim b/tests/pass/single_test/hello_world.nim deleted file mode 100644 index d8a6566..0000000 --- a/tests/pass/single_test/hello_world.nim +++ /dev/null @@ -1,2 +0,0 @@ -func hello*: string = - "Hello, World!" diff --git a/tests/pass/single_test/identity.nim b/tests/pass/single_test/identity.nim new file mode 100644 index 0000000..604702b --- /dev/null +++ b/tests/pass/single_test/identity.nim @@ -0,0 +1,2 @@ +func identity*(n: int): int = + n diff --git a/tests/pass/single_test/test_hello_world.nim b/tests/pass/single_test/test_hello_world.nim deleted file mode 100644 index f0bfcb0..0000000 --- a/tests/pass/single_test/test_hello_world.nim +++ /dev/null @@ -1,8 +0,0 @@ -import std/unittest -import hello_world - -# version 1.1.0 - -suite "Hello World": - test "say hi!": - check hello() == "Hello, World!" diff --git a/tests/pass/single_test/test_identity.nim b/tests/pass/single_test/test_identity.nim new file mode 100644 index 0000000..f0ebd38 --- /dev/null +++ b/tests/pass/single_test/test_identity.nim @@ -0,0 +1,6 @@ +import std/unittest +import identity + +suite "Identity Function": + test "identity function of 1": + check identity(1) == 1