diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4d780782..0575e016c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,11 +146,11 @@ jobs: - name: Optimized Core library tests run: ./odin test tests/core/speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true - name: Wycheproof tests - run: ./odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + run: ./odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Noise Protocol Framework tests - run: ./odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + run: ./odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: X.509 limbo tests - run: ./odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + run: ./odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Vendor library tests run: ./odin test tests/vendor -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address if: matrix.os != 'macos-latest' @@ -255,17 +255,17 @@ jobs: shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + odin test tests/core/crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Noise Protocol Framework tests shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + odin test tests/core/crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: X.509 limbo tests shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -o:speed + odin test tests/core/crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed - name: Vendor library tests shell: cmd run: | diff --git a/.gitignore b/.gitignore index 81e2bb7ff..62e36469d 100644 --- a/.gitignore +++ b/.gitignore @@ -308,10 +308,9 @@ build.sh # RAD debugger project file *.raddbg *.rdi -tests/issues/build/* -tests/abi/build/* -tests/abi/build-cross/* -tests/debug_info/build/* + +# NOTE: The /tests/** directories have their own .gitignore files + misc/featuregen/featuregen # Clangd stuff diff --git a/run_tests.bat b/run_tests.bat new file mode 100644 index 000000000..e383e811e --- /dev/null +++ b/run_tests.bat @@ -0,0 +1,123 @@ +@rem This file runs most of the tests that the CI would run. +@rem When the "slim" argument is provided, it omits time-intensive optimized core library tests and Wycheproof tests. + +setlocal EnableDelayedExpansion + +@echo off + +set SLIM= + +for %%A in (%*) do ( + if "%%A"=="slim" ( + set SLIM=1 + ) else if "%%A"=="no-clang" ( + set ODIN_TESTS_NO_CLANG=1 + ) else ( + echo Unrecognized argument: %%A + exit /b + ) +) + +rem Check if clang is present +if not defined ODIN_TESTS_NO_CLANG ( + clang --version + if !ERRORLEVEL! neq 0 ( + echo ERROR: clang is not present. Some tests require this. + echo Note: You can try using msvc instead by specifying the "no-clang" argument, or setting ODIN_TESTS_NO_CLANG=1 + echo However, some ABI tests will be skipped. + exit /b + ) +) + +@echo on + +@rem Check examples/all +@pushd . +.\odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do || exit /b +@popd + +@rem Check examples/all/sdl3 +@pushd . +.\odin check examples\all\sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point || exit /b +@popd + +@rem Internals tests +@pushd tests\internal +..\..\odin test . -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address || exit /b +@popd + +@rem Normal Core library tests +@pushd tests\core +..\..\odin test normal.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address || exit /b +@popd + +@rem Vendor library tests +@pushd . +cd tests\vendor +mkdir build +pushd build +copy ..\..\..\vendor\lua\5.4\windows\*.dll . +..\..\..\odin test ..\ -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address || exit /b +popd +rmdir /S /Q build +@popd + +@rem Check issues +@pushd . +cd tests\issues +call run.bat || exit /b +@popd + +@rem The ABI tests can be disabled here because they require clang at the moment. +@rem TODO: Maybe try to make them work with msvc as well? +if not defined ODIN_TESTS_NO_CLANG ( + + @rem Run ABI tests + @pushd . + cd tests\abi + set ABI_CFLAGS= + call run.bat || exit /b + set ABI_CFLAGS=-O2 + call run.bat -o:speed || exit /b + @popd + +) + +@rem More extensive tests (non-slim): + +if not defined SLIM ( + + @echo Running extended tests... + + @rem Optimized Core library tests + @pushd tests\core + ..\..\odin test speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true || exit /b + @popd + + @rem Wycheproof tests + @pushd tests\core + ..\..\odin test crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed || exit /b + @popd + + @rem Noise Protocol Framework tests + @pushd tests\core + ..\..\odin test crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed || exit /b + @popd + + @rem X.509 limbo tests + @pushd tests\core + ..\..\odin test crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed || exit /b + @popd + + @echo SUCCESS: Extended tests have been executed successfully. + @echo Note: You can call "run_tests slim" to omit some of the slower tests. + +) else ( + + @echo SUCCESS: Slim tests have been executed successfully. + +) + +if defined ODIN_TESTS_NO_CLANG ( + @echo WARNING: ODIN_TESTS_NO_CLANG specified - ABI tests have been skipped. +) diff --git a/run_tests.sh b/run_tests.sh new file mode 100644 index 000000000..648cc34b2 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +set -eu + +# This file runs most of the tests that the CI would run. +# It omits time-intensive optimized core library tests and Wycheproof tests. + +here=$(cd "$(dirname "$0")" && pwd) +: "${ODIN:=$here/odin}" + +SLIM= +for arg in "$@"; do + case "$arg" in + slim) + SLIM=1 + ;; + no-clang) + export ODIN_TESTS_NO_CLANG=1 + ;; + *) + echo "Unrecognized argument: $arg" + exit 1 + ;; + esac +done + +if [[ -z "${ODIN_TESTS_NO_CLANG:-}" ]]; then + if ! clang --version >/dev/null 2>&1; then + echo "ERROR: clang is not present. Some tests require this." + echo "Note: You can disable tests that require clang by specifying the \"no-clang\" argument, or setting ODIN_TESTS_NO_CLANG=1" + # TODO: Can we figure out how to make everything work with gcc as well when ODIN_TESTS_NO_CLANG is set? + exit 1 + fi +fi + +# Check examples/all +"$ODIN" check "$here/examples/all" -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do + +# Check examples/all/sdl3 +"$ODIN" check "$here/examples/all/sdl3" -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point + +# Internals tests +( + cd "$here/tests/internal" + "$ODIN" test . -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address +) + +# Normal Core library tests +( + cd "$here/tests/core" + "$ODIN" test normal.odin -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address +) + +# Vendor library tests +vendor_build="$here/tests/vendor/build" +mkdir -p "$vendor_build" +cp "$here"/vendor/lua/5.4/linux/*.so "$vendor_build"/ +# We are possibly on Windows, so copy the DLLs as well. +cp "$here"/vendor/lua/5.4/windows/*.dll "$vendor_build"/ +( + cd "$vendor_build" + LD_LIBRARY_PATH="$vendor_build${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" "$ODIN" test .. -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true -sanitize:address +) +rm -rf "$vendor_build" + +# Check issues +( + cd "$here/tests/issues" + ./run.sh +) + +# The ABI tests can be disabled because they require clang at the moment. +# TODO: Maybe try to make them work with msvc as well? +if [[ -z "${ODIN_TESTS_NO_CLANG:-}" ]]; then + # Run ABI tests + ( + cd "$here/tests/abi" + ABI_CFLAGS= ./run.sh + ABI_CFLAGS=-O2 ./run.sh -o:speed + ) +fi + +# More extensive tests (non-slim): +if [[ -z "${SLIM:-}" ]]; then + + echo "Running extended tests..." + + # Optimized Core library tests + ( + cd "$here/tests/core" + "$ODIN" test speed.odin -o:speed -file -all-packages -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true + ) + + # Wycheproof tests + ( + cd "$here/tests/core" + "$ODIN" test crypto/wycheproof -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed + ) + + # Noise Protocol Framework tests + ( + cd "$here/tests/core" + "$ODIN" test crypto/noise -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed + ) + + # X.509 limbo tests + ( + cd "$here/tests/core" + "$ODIN" test crypto/x509_limbo -vet -vet-tabs -strict-style -vet-style -vet-cast -warnings-as-errors -disallow-do -define:ODIN_TEST_FANCY=false -o:speed + ) + + echo "SUCCESS: Extended tests have been executed successfully." + echo "Note: You can call \"run_tests slim\" to omit some of the slower tests." + +else + echo "SUCCESS: Slim tests have been executed successfully." + +fi + +if [[ -n "${ODIN_TESTS_NO_CLANG:-}" ]]; then + echo "WARNING: ODIN_TESTS_NO_CLANG specified - ABI tests have been skipped." +fi diff --git a/src/check_escape.cpp b/src/check_escape.cpp index 24a8e5abb..1484271ef 100644 --- a/src/check_escape.cpp +++ b/src/check_escape.cpp @@ -3396,6 +3396,7 @@ gb_internal void escape_stmt(EscapeAnalysis *ea, Ast *node) { case_end; case_ast_node(rs, RangeStmt, node); + escape_stmt(ea, rs->init); Ast *val0 = nullptr; Ast *val1 = nullptr; if (rs->vals.count > 0) { @@ -3416,9 +3417,11 @@ gb_internal void escape_stmt(EscapeAnalysis *ea, Ast *node) { escape_nil_scan(ea, rs->expr); } escape_loop(ea, node, nullptr, nullptr, rs->body, val0, val1, rs->expr); + escape_forget(ea, rs->init); case_end; case_ast_node(rs, UnrollRangeStmt, node); + escape_stmt(ea, rs->init); bool by_ref = false; Ast *vals[2] = {rs->val0, rs->val1}; for (Ast *val : vals) { @@ -3431,6 +3434,7 @@ gb_internal void escape_stmt(EscapeAnalysis *ea, Ast *node) { escape_nil_scan(ea, rs->expr); } escape_loop(ea, node, nullptr, nullptr, rs->body, rs->val0, rs->val1, rs->expr); + escape_forget(ea, rs->init); case_end; case_ast_node(ss, SwitchStmt, node); diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 504a22ee9..d6593a85a 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -3885,6 +3885,10 @@ general_end:; max_align = gb_max(max_align, 16); LLVMValueRef ptr = llvm_alloca(p, dst_type, max_align); + if (dst_size > src_size) { + // NOTE(bill): the bytes past `src` are padding and must read as zero + LLVMBuildStore(p->builder, LLVMConstNull(dst_type), ptr); + } LLVMValueRef nptr = LLVMBuildPointerCast(p->builder, ptr, LLVMPointerType(src_type, 0), ""); LLVMBuildStore(p->builder, val, nptr); diff --git a/tests/abi/.gitignore b/tests/abi/.gitignore index e390b124a..ecc2bbb49 100644 --- a/tests/abi/.gitignore +++ b/tests/abi/.gitignore @@ -1 +1,2 @@ -build/** \ No newline at end of file +build/** +build-cross/** diff --git a/tests/abi/run.bat b/tests/abi/run.bat index db03eda3b..e61cb5073 100644 --- a/tests/abi/run.bat +++ b/tests/abi/run.bat @@ -24,6 +24,7 @@ REM Odin side needs to match set TIER_GNU=false set TIER_F16=false set TIER_I128=false +clang --version || exit /b clang -E tiers.c 2>nul | findstr /C:"ABI_YES_GNU" >nul && set TIER_GNU=true clang -E tiers.c 2>nul | findstr /C:"ABI_YES_F16" >nul && set TIER_F16=true clang -E tiers.c 2>nul | findstr /C:"ABI_YES_I128" >nul && set TIER_I128=true diff --git a/tests/abi/run.sh b/tests/abi/run.sh index 80bc273f6..1275d4a74 100755 --- a/tests/abi/run.sh +++ b/tests/abi/run.sh @@ -25,7 +25,9 @@ here=$(cd "$(dirname "$0")" && pwd) COMMON="-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused-defineables" CC_TARGET=""; [ -n "$TRIPLE" ] && CC_TARGET="--target=$TRIPLE" -ODIN_TARGET="-microarch:native"; [ -n "$TARGET" ] && ODIN_TARGET="-target:$TARGET" + +HOST_MARCH=""; case "$(uname -m)" in x86_64|amd64) HOST_MARCH="-microarch:x86-64" ;; esac +ODIN_TARGET="$HOST_MARCH"; [ -n "$TARGET" ] && ODIN_TARGET="-target:$TARGET" # Cleaned BEFORE, not after: the generated corpus is left in place so it can be @@ -36,7 +38,7 @@ pushd "$here/build" > /dev/null set -x -$ODIN run ../gen.odin -file -microarch:native -- . +$ODIN run ../gen.odin -file $HOST_MARCH -- . # Ask the C compiler which tiers it has, by preprocessing the generated `build-cross/tiers.c`. # The Odin side must use the same tiers or it references symbols C never emitted. diff --git a/tests/core/download_assets.py b/tests/core/download_assets.py index 6e6bf83b8..11b984612 100644 --- a/tests/core/download_assets.py +++ b/tests/core/download_assets.py @@ -698,6 +698,8 @@ def main(): debug = True for suite in TEST_SUITES: + print("Downloading test assets: {}\n".format(suite)) + sys.stdout.flush() base_path = sys.argv[1] + "/{}".format(suite) # Make assets path try: @@ -712,6 +714,7 @@ def main(): # We could fall back on downloading the PNG files individually, but it's slow print("Done downloading {} assets.\n".format(suite)) + sys.stdout.flush() return 0 diff --git a/tests/issues/.gitignore b/tests/issues/.gitignore new file mode 100644 index 000000000..f65519e3c --- /dev/null +++ b/tests/issues/.gitignore @@ -0,0 +1 @@ +build/** diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 3473e9614..1a2f0df7d 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -1,9 +1,10 @@ @echo off +setlocal EnableDelayedExpansion if not exist "build\" mkdir build pushd build -set COMMON=-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables +set COMMON=-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -show-timings set ODIN=..\..\..\odin @echo on @@ -33,9 +34,9 @@ set ODIN=..\..\..\odin @rem "odin check" tests: %ODIN% check "..\test_issue_5105_5569" %COMMON% 2>&1 | find /c "Error:" | findstr /x "4" || exit /b -%ODIN% check "..\test_issue_6484" -no-entry-point %COMMON% || exit /b +%ODIN% check "..\test_issue_6484" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_6874" %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b -%ODIN% check "..\test_issue_6979" -no-entry-point %COMMON% || exit /b +%ODIN% check "..\test_issue_6979" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_7012" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_7260" -no-entry-point %COMMON% || exit /b %ODIN% check "..\test_issue_7304" %COMMON% 2>&1 | find /c "9223372036854775808 is not representable by int" | findstr /x "1" || exit /b @@ -92,8 +93,30 @@ set ODIN=..\..\..\odin @rem ######################################################################################################### +@rem Test clang - improve error message for users that don't have it. + +@if "%ODIN_TESTS_NO_CLANG%" == "" ( + @echo Testing for clang... + clang --version + if !ERRORLEVEL! neq 0 ( + @echo ERROR: clang not working. This is required for some tests. + @echo You can try msvc instead: set ODIN_TESTS_NO_CLANG=1 + exit /b + ) +) else ( + @echo Testing for msvc... + cl + if !ERRORLEVEL! neq 0 ( + @echo ERROR: msvc not working. This is required for some tests. + @echo You can try clang instead: set ODIN_TESTS_NO_CLANG= + exit /b + ) +) + +@rem ######################################################################################################### + @rem "odin test" tests with special needs, or others (e.g. "odin doc"): -if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ODIN_TESTS_NO_CLANG%" == "" ( clang -c "..\test_issue_5640\test_issue_5640.c" -o test_issue_5640_c.o || exit /b ) else ( cl -c "..\test_issue_5640\test_issue_5640.c" /Fo:test_issue_5640_c.o || exit /b @@ -101,7 +124,7 @@ if "%ISSUES_TESTS_NO_CLANG%" == "" ( %ODIN% test "..\test_issue_5640" %COMMON% || exit /b -if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ODIN_TESTS_NO_CLANG%" == "" ( clang -c "..\test_issue_6809_6816\test_issue_6809_6816.c" -o test_issue_6809_6816_c.o -O3 || exit /b ) else ( cl -c "..\test_issue_6809_6816\test_issue_6809_6816.c" /Fo:test_issue_6809_6816_c.o -O3 || exit /b @@ -120,7 +143,7 @@ fc /b pr_7848.cbor pr_7848_again.cbor > nul || exit /b %ODIN% test "..\test_pr_7848" %COMMON% || exit /b @rem It seems at this point 7010 is not for Windows. -@rem if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@rem @if "%ODIN_TESTS_NO_CLANG%" == "" ( @rem clang -c "..\test_issue_7010\test_issue_7010.c" -o test_issue_7010_c.o || exit /b @rem %ODIN% test "..\test_issue_7010" %COMMON% || exit /b @rem ) else ( @@ -140,7 +163,7 @@ fc /b pr_7848.cbor pr_7848_again.cbor > nul || exit /b %ODIN% test "..\test_lifetime_markers" %COMMON% -o:size -lifetime-markers || exit /b %ODIN% test "..\test_lifetime_markers" %COMMON% -o:speed -lifetime-markers || exit /b -if "%ISSUES_TESTS_NO_CLANG%" == "" ( +@if "%ODIN_TESTS_NO_CLANG%" == "" ( clang -c "..\test_issue_sysv_abi\test_issue_sysv_abi.c" -o test_issue_sysv_abi_c.o || exit /b ) else ( cl -c "..\test_issue_sysv_abi\test_issue_sysv_abi.c" /Fo:test_issue_sysv_abi_c.o || exit /b diff --git a/tests/issues/run.sh b/tests/issues/run.sh index a04cf76ef..73d886cb7 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -4,8 +4,8 @@ set -eu mkdir -p build pushd build ODIN=../../../odin -COMMON="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -microarch:native" -COMMON_CHECK="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables" +COMMON="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -show-timings -microarch:native" +COMMON_CHECK="-define:ODIN_TEST_FANCY=false -vet -strict-style -ignore-unused-defineables -show-timings" set -x @@ -18,7 +18,7 @@ set -x # update `run.bat` as well. # Some tests require a C compiler. -# By default, it uses clang. export ISSUES_TESTS_NO_CLANG=1 to disable these tests. +# By default, it uses clang. export ODIN_TESTS_NO_CLANG=1 to disable these tests. # TODO: See if we can make the tests work with gcc instead? ######################################################################################################### @@ -276,11 +276,26 @@ $ODIN run ../test_issue_7798 $COMMON ######################################################################################################### +# +# Test clang - improve error message for users that don't have it. +# + +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then + if ! clang --version; then + set +x + echo "ERROR: clang not working. This is required for some tests." + echo "You can disable tests that require clang: export ODIN_TESTS_NO_CLANG=1" + exit 1 + fi +fi + +######################################################################################################### + # # "odin test" tests with special needs, or others (e.g. "odin doc"): # -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_5640/test_issue_5640.c -o test_issue_5640_c.o if [[ "$(uname)" != "NetBSD" ]]; then @@ -290,7 +305,7 @@ if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then fi fi -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_6809_6816/test_issue_6809_6816.c -o test_issue_6809_6816_c.o -O3 $ODIN test ../test_issue_6809_6816 -o:speed $COMMON fi @@ -310,7 +325,7 @@ $ODIN check ../test_pr_7848/pkg_b ../test_pr_7848/pkg_a -no-entry-point -workspa cmp pr_7848.cbor pr_7848_again.cbor $ODIN test ../test_pr_7848 $COMMON -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_7010/test_issue_7010.c -o test_issue_7010_c.o $ODIN test ../test_issue_7010 $COMMON fi @@ -348,13 +363,13 @@ fi $ODIN test ../test_lifetime_markers $COMMON -o:size -lifetime-markers $ODIN test ../test_lifetime_markers $COMMON -o:speed -lifetime-markers -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then clang -c ../test_issue_sysv_abi/test_issue_sysv_abi.c -o test_issue_sysv_abi_c.o $ODIN test ../test_issue_sysv_abi $COMMON fi # AVX-512 asked for through -target-features on the default microarch; needs a CPU that has it -if [[ -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ -z ${ODIN_TESTS_NO_CLANG+x} ]]; then if grep -qw avx512f /proc/cpuinfo 2>/dev/null; then clang -c ../test_issue_avx512_vector_abi/test_issue_avx512_vector_abi.c -o test_issue_avx512_vector_abi_c.o -mavx512f $ODIN test ../test_issue_avx512_vector_abi $COMMON_CHECK -target-features:avx512f @@ -366,7 +381,7 @@ $ODIN test ../test_issue_loaded_pointer_alignment $COMMON -o:speed ######################################################################################################### -if [[ ! -z ${ISSUES_TESTS_NO_CLANG+x} ]]; then +if [[ ! -z ${ODIN_TESTS_NO_CLANG+x} ]]; then echo "!!! WARNING !!! Tests that require clang have been skipped" fi diff --git a/tests/vendor/.gitignore b/tests/vendor/.gitignore new file mode 100644 index 000000000..f65519e3c --- /dev/null +++ b/tests/vendor/.gitignore @@ -0,0 +1 @@ +build/**