Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Apr 5, 2024
1 parent 134bbf2 commit 150d27a
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 42 deletions.
13 changes: 5 additions & 8 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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": []
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import std/unittest
import hello_world
import identity

# version 1.1.0

Expand Down
4 changes: 2 additions & 2 deletions tests/pass/single_test/expected_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
20 changes: 0 additions & 20 deletions tests/pass/single_test/expected_test_hello_world_prepared.nim

This file was deleted.

2 changes: 0 additions & 2 deletions tests/pass/single_test/hello_world.nim

This file was deleted.

2 changes: 2 additions & 0 deletions tests/pass/single_test/identity.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
func identity*(n: int): int =
n
8 changes: 0 additions & 8 deletions tests/pass/single_test/test_hello_world.nim

This file was deleted.

6 changes: 6 additions & 0 deletions tests/pass/single_test/test_identity.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import std/unittest
import identity

suite "Identity Function":
test "identity function of 1":
check identity(1) == 1

0 comments on commit 150d27a

Please sign in to comment.