From a8e9f0abcc5cfd4f3556a838a9b0a0b52b31e52f Mon Sep 17 00:00:00 2001 From: Akuli Date: Sun, 3 Dec 2023 12:30:05 +0200 Subject: [PATCH] fixed --- .github/workflows/linux.yml | 6 +++--- compare_compilers.sh | 3 ++- examples/aoc2023/day01/part1.jou | 2 ++ examples/aoc2023/day01/part2.jou | 2 ++ examples/aoc2023/day02/part1.jou | 2 ++ examples/aoc2023/day02/part2.jou | 2 ++ runtests.sh | 19 +++++++++---------- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2cd25d68..8ef22f5e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -22,8 +22,8 @@ jobs: - uses: actions/checkout@v3 - run: sudo apt install -y llvm-${{ matrix.llvm-version }}-dev clang-${{ matrix.llvm-version }} make valgrind - run: LLVM_CONFIG=llvm-config-${{ matrix.llvm-version }} make - - run: ./runtests.sh --verbose './jou ${{ matrix.opt-level }} %s' - - run: ./runtests.sh --verbose './jou ${{ matrix.opt-level }} --verbose %s' + - run: ./runtests.sh --verbose 'jou ${{ matrix.opt-level }} %s' + - run: ./runtests.sh --verbose 'jou ${{ matrix.opt-level }} --verbose %s' # Valgrinding is slow. Do it only when this file or something in the compiler has been modified. - name: Figure out if we need to run tests with valgrind id: check-need-valgrind @@ -35,7 +35,7 @@ jobs: echo doit=no >> $GITHUB_OUTPUT fi - if: ${{ steps.check-need-valgrind.outputs.doit == 'yes' }} - run: ./runtests.sh --verbose --valgrind './jou ${{ matrix.opt-level }} %s' + run: ./runtests.sh --verbose --valgrind 'jou ${{ matrix.opt-level }} %s' # valgrind+verbose isn't meaningful: test script would ignore valgrind output - run: make clean - name: Check that "make clean" deleted all files not committed to Git diff --git a/compare_compilers.sh b/compare_compilers.sh index d730e2b3..6f20b51b 100755 --- a/compare_compilers.sh +++ b/compare_compilers.sh @@ -28,7 +28,8 @@ for arg in "$@"; do done if [ ${#files[@]} = 0 ]; then - mapfile -t files < <( find stdlib examples tests -name '*.jou' | sort ) + # TODO: do not skip Advent Of Code files + mapfile -t files < <( find stdlib examples tests -name '*.jou' | grep -v aoc2023 | sort ) fi if [ ${#actions[@]} = 0 ]; then actions=(tokenize parse run) diff --git a/examples/aoc2023/day01/part1.jou b/examples/aoc2023/day01/part1.jou index 47b234b5..b0a28bb0 100644 --- a/examples/aoc2023/day01/part1.jou +++ b/examples/aoc2023/day01/part1.jou @@ -21,5 +21,7 @@ def main() -> int: result += 10*(*first - '0') result += *last - '0' + fclose(f) + printf("%d\n", result) # Output: 54630 return 0 diff --git a/examples/aoc2023/day01/part2.jou b/examples/aoc2023/day01/part2.jou index 050f62f4..1ff43ea4 100644 --- a/examples/aoc2023/day01/part2.jou +++ b/examples/aoc2023/day01/part2.jou @@ -33,5 +33,7 @@ def main() -> int: result += 10*parse_prefix_digit(first) result += parse_prefix_digit(last) + fclose(f) + printf("%d\n", result) # Output: 54770 return 0 diff --git a/examples/aoc2023/day02/part1.jou b/examples/aoc2023/day02/part1.jou index 9bb5c0cf..e9b2593c 100644 --- a/examples/aoc2023/day02/part1.jou +++ b/examples/aoc2023/day02/part1.jou @@ -47,5 +47,7 @@ def main() -> int: if game_is_possible(&id_end[1]): result += game_id + fclose(f) + printf("%d\n", result) # Output: 1853 return 0 diff --git a/examples/aoc2023/day02/part2.jou b/examples/aoc2023/day02/part2.jou index 6e537672..0cef5566 100644 --- a/examples/aoc2023/day02/part2.jou +++ b/examples/aoc2023/day02/part2.jou @@ -56,5 +56,7 @@ def main() -> int: game = parse_game(&id_end[1]) result += game.get_power() + fclose(f) + printf("%d\n", result) # Output: 72706 return 0 diff --git a/runtests.sh b/runtests.sh index ca804f3f..f5a30cd3 100755 --- a/runtests.sh +++ b/runtests.sh @@ -170,16 +170,15 @@ function run_test() fi show_run $joufile - if diff --text -u --color=always \ - <(cd $dir; generate_expected_output $joufile $correct_exit_code | tr -d '\r') \ - <( - export PATH="$PWD:$PATH" - cd $dir - ulimit -v 500000 2>/dev/null - bash -c "$command; echo Exit code: \$?" 2>&1 | post_process_output $joufile | tr -d '\r' - ) \ - &>> $diffpath - then + if diff --text -u --color=always <( + cd $dir + generate_expected_output $joufile $correct_exit_code | tr -d '\r' + ) <( + export PATH="$PWD:$PATH" + cd $dir + ulimit -v 500000 2>/dev/null + bash -c "$command; echo Exit code: \$?" 2>&1 | post_process_output $joufile | tr -d '\r' + ) &>> $diffpath; then show_ok $joufile rm -f $diffpath else