From 8646e6f693fd935c6cb81e776a6c92a3fd093a33 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 23 Aug 2025 17:41:23 +0900 Subject: feat: output executable using gcc --- tests/098.sh | 16 ++++++++++++++++ tests/test_helpers.sh | 19 +++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 tests/098.sh (limited to 'tests') diff --git a/tests/098.sh b/tests/098.sh new file mode 100644 index 0000000..33c4f17 --- /dev/null +++ b/tests/098.sh @@ -0,0 +1,16 @@ +cat > foo.c <<'EOF' +int main() {} +EOF + +"$ducc" -o bar.s foo.c +if [[ $? -ne 0 ]]; then + exit 1 +fi +gcc -o a.out bar.s +./a.out "$@" +exit_code=$? + +if [[ $exit_code -ne 0 ]]; then + echo "invalid exit code: $exit_code" >&2 + exit 1 +fi diff --git a/tests/test_helpers.sh b/tests/test_helpers.sh index 9169c24..349dc3a 100644 --- a/tests/test_helpers.sh +++ b/tests/test_helpers.sh @@ -2,12 +2,7 @@ function test_exit_code() { set +e cat > main.c - "$ducc" main.c > main.s - if [[ $? -ne 0 ]]; then - set -e - exit 1 - fi - gcc -o a.out main.s + "$ducc" -o a.out main.c ./a.out exit_code=$? @@ -24,11 +19,7 @@ function test_exit_code() { function test_diff() { cat > main.c - "$ducc" main.c > main.s - if [[ $? -ne 0 ]]; then - exit 1 - fi - gcc -o a.out main.s + "$ducc" -o a.out main.c if [[ ! -f input ]]; then touch input fi @@ -61,11 +52,7 @@ function test_compile_error() { function test_example() { filename="../../../examples/$1.c" - "$ducc" "$filename" > main.s - if [[ $? -ne 0 ]]; then - exit 1 - fi - gcc -o a.out main.s + "$ducc" -o a.out "$filename" if [[ ! -f input ]]; then touch input fi -- cgit v1.2.3-70-g09d2