Skip to content

Commit

Permalink
runtests.sh updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Jan 8, 2025
1 parent e54203e commit 87bd7cb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt update
- run: sudo apt install -y llvm-${{ matrix.llvm-version }}-dev clang-${{ matrix.llvm-version }} make
- run: LLVM_CONFIG=llvm-config-${{ matrix.llvm-version }} make
- name: "Test stage 1 compiler"
- run: echo "LLVM_CONFIG=llvm-config-${{ matrix.llvm-version }}" >> $GITHUB_ENV
- name: "Compile and test stage 1 compiler"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}" --stage1
- name: "Test stage 2 compiler"
- name: "Compile and test stage 2 compiler"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}" --stage2
- name: "Test stage 3 compiler"
- name: "Compile and test stage 3 compiler"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}"
- name: "Test stage 3 compiler with the compiler's --verbose flag"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }} --verbose"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
- run: brew install bash diffutils llvm@14

- run: make
- name: "Test stage 1 compiler"
- name: "Compile and test stage 1 compiler"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}" --stage1
- name: "Test stage 2 compiler"
- name: "Compile and test stage 2 compiler"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}" --stage2
- name: "Test stage 3 compiler"
- name: "Compile and test stage 3 compiler"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }}"
- name: "Test stage 3 compiler with the compiler's --verbose flag"
run: ./runtests.sh --verbose --jou-flags "${{ matrix.opt-level }} --verbose"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ jobs:
path: "test dir"
- run: cd "test dir" && ./windows_setup.sh --small
shell: bash
- name: "Test stage 1 compiler"
- name: "Compile and test stage 1 compiler"
run: cd "test dir" && source activate && ./runtests.sh --verbose --stage1
shell: bash
- name: "Test stage 2 compiler"
- name: "Compile and test stage 2 compiler"
run: cd "test dir" && source activate && ./runtests.sh --verbose --stage2
shell: bash
- name: "Test stage 3 compiler"
- name: "Compile and test stage 3 compiler"
run: cd "test dir" && source activate && ./runtests.sh --verbose
shell: bash

Expand Down
49 changes: 30 additions & 19 deletions runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export LANG=C # "Segmentation fault" must be in english for this script to work
set -e -o pipefail

function usage() {
echo "Usage: $0 [--valgrind] [--verbose] [--dont-run-make] [--jou-flags \"-O3 ...\"] [FILE_FILTER]" >&2
echo "Usage: $0 [--valgrind] [--verbose] [--stage1 | --stage2] [--dont-run-make] [--jou-flags \"-O3 ...\"] [FILE_FILTER]" >&2
echo ""
echo "By default, this tests the stage 3 compiler (see bootstrapping in README). Use"
echo "--stage1 or --stage2 to test other stages as needed."
Expand Down Expand Up @@ -80,18 +80,6 @@ if [ $valgrind = yes ]; then
esac
fi

if [ $run_make = yes ]; then
if [[ "${OS:=$(uname)}" =~ Windows ]]; then
source activate
mingw32-make
elif [[ "$OS" =~ NetBSD ]]; then
gmake
else
make
fi

fi

DIFF=$(which gdiff || which diff)
if $DIFF --help | grep -q -- --color; then
diff_color="--color=always"
Expand Down Expand Up @@ -123,6 +111,17 @@ fi
echo "<joudir> in expected output will be replaced with $joudir."
echo "<jouexe> in expected output will be replaced with $jouexe."

if [ $run_make = yes ]; then
if [[ "${OS:=$(uname)}" =~ Windows ]]; then
source activate
mingw32-make $jouexe
elif [[ "$OS" =~ NetBSD ]]; then
gmake $jouexe
else
make $jouexe
fi
fi

function generate_expected_output()
{
local joufile="$1"
Expand Down Expand Up @@ -211,13 +210,19 @@ function run_test()

local command=""

if [ $stage = 3 ]; then
command="jou"
else
command="stage$stage" # in "bootstrap" folder, PATH is adjusted in other part of this script
fi

if [[ "$OS" =~ Windows ]]; then
command="$command.exe"
fi

if [ $valgrind = yes ] && [ $correct_exit_code == 0 ]; then
# Valgrind the compiler process and the compiled executable
command="valgrind -q --leak-check=full --show-leak-kinds=all --suppressions='$(pwd)/valgrind-suppressions.sup' jou --valgrind"
elif [[ "$OS" =~ Windows ]]; then
command="jou.exe"
else
command="jou"
command="valgrind -q --leak-check=full --show-leak-kinds=all --suppressions='$(pwd)/valgrind-suppressions.sup' $jouexe --valgrind"
fi

# jou flags start with space when non-empty
Expand Down Expand Up @@ -245,7 +250,13 @@ function run_test()
if $DIFF --text -u $diff_color <(
generate_expected_output $joufile $correct_exit_code | tr -d '\r'
) <(
export PATH="$PWD:$PATH"
if [ $stage == 3 ]; then
export PATH="$PWD:$PATH"
else
# stage1 and stage2 executables are in "bootstrap/" folder
export PATH="$PWD/bootstrap:$PATH"
fi
if [ $valgrind = no ]; then
ulimit -v 500000 2>/dev/null
fi
Expand Down

0 comments on commit 87bd7cb

Please sign in to comment.