From 654b96933c31b077885f91a68310398c6dbbb3d6 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Fri, 7 Feb 2025 10:50:07 +0200 Subject: Add test for visibility in translation unit with multiple source files (#6306) This closes #6221. --- tools/slangc-test/multiple-source-files/A.slang | 3 ++ .../multiple-source-files/source1.slang | 6 +++ .../multiple-source-files/source2.slang | 2 + tools/slangc-test/test.sh | 44 ++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 tools/slangc-test/multiple-source-files/A.slang create mode 100644 tools/slangc-test/multiple-source-files/source1.slang create mode 100644 tools/slangc-test/multiple-source-files/source2.slang create mode 100755 tools/slangc-test/test.sh (limited to 'tools') diff --git a/tools/slangc-test/multiple-source-files/A.slang b/tools/slangc-test/multiple-source-files/A.slang new file mode 100644 index 000000000..6dcbd8e29 --- /dev/null +++ b/tools/slangc-test/multiple-source-files/A.slang @@ -0,0 +1,3 @@ +module A; + +public int test() { return 1; } \ No newline at end of file diff --git a/tools/slangc-test/multiple-source-files/source1.slang b/tools/slangc-test/multiple-source-files/source1.slang new file mode 100644 index 000000000..22a561de2 --- /dev/null +++ b/tools/slangc-test/multiple-source-files/source1.slang @@ -0,0 +1,6 @@ +module source1; + +import A; + +[shader("compute")] +void computeMain1() { int a = test(); } \ No newline at end of file diff --git a/tools/slangc-test/multiple-source-files/source2.slang b/tools/slangc-test/multiple-source-files/source2.slang new file mode 100644 index 000000000..d1f5199e0 --- /dev/null +++ b/tools/slangc-test/multiple-source-files/source2.slang @@ -0,0 +1,2 @@ +[shader("compute")] +void computeMain2() { } \ No newline at end of file diff --git a/tools/slangc-test/test.sh b/tools/slangc-test/test.sh new file mode 100755 index 000000000..858f24d23 --- /dev/null +++ b/tools/slangc-test/test.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -e + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + +summary=() +failure_count=0 +test_count=0 + +test() { + local name + local exit_code + name=$1 + shift + pushd "$name" 1>/dev/null 2>&1 + echo "Running $name..." + "$@" || exit_code=$? + summary=("${summary[@]}" "$name: ") + if [[ $exit_code -eq 0 ]]; then + summary=("${summary[@]}" " success") + else + summary=("${summary[@]}" " failure (exit code: $exit_code)") + fi + popd 1>/dev/null 2>&1 + echo + test_count=$((test_count + 1)) +} + +cd "${script_dir}" + +test multiple-source-files slangc source1.slang source2.slang + +echo "" +echo "Summary: " +echo +for line in "${summary[@]}"; do + printf ' %s\n' "$line" +done +echo "" +echo "$failure_count failed, out of $test_count tests" +if [[ $failure_count -ne 0 ]]; then + exit 1 +fi -- cgit v1.2.3