Skip to content

Commit 496a00d

Browse files
committed
Add differential testing harness
This runs wgsl shaders and rust shaders and compares the output. If the output differs, the test fails. Differential testing is better than snapshot testing or golden file testing as there are no reference files to get outdated.
1 parent 3b60bf9 commit 496a00d

File tree

326 files changed

+3391
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+3391
-80
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[alias]
22
compiletest = "run --release -p compiletests --"
3+
difftest = "run --release -p difftests --"
34

45

56
[target.x86_64-pc-windows-msvc]

.github/workflows/ci.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ jobs:
4242
- if: ${{ runner.os == 'Linux' }}
4343
name: Linux - Install native dependencies
4444
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
45+
- if: ${{ runner.os == 'Linux' }}
46+
name: Install xvfb, llvmpipe and lavapipe
47+
run: |
48+
sudo apt-get update -y -qq
49+
sudo add-apt-repository ppa:kisak/turtle -y
50+
sudo apt-get update
51+
sudo apt install -y xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
4552
# cargo version is a random command that forces the installation of rust-toolchain
4653
- name: install rust-toolchain
4754
run: cargo version
@@ -64,6 +71,10 @@ jobs:
6471
if: ${{ matrix.target != 'aarch64-linux-android' }}
6572
run: cargo run -p compiletests --release --no-default-features --features "use-installed-tools" -- --target-env vulkan1.1,vulkan1.2,spv1.3
6673

74+
- name: difftest
75+
if: ${{ matrix.target != 'aarch64-linux-android' }}
76+
run: cargo run -p difftests --release --no-default-features --features "use-installed-tools"
77+
6778
- name: workspace test
6879
if: ${{ matrix.target != 'aarch64-linux-android' }}
6980
run: cargo test --release
@@ -145,8 +156,10 @@ jobs:
145156
run: cargo fetch --locked
146157
- name: Rustfmt
147158
run: cargo fmt --all -- --check
148-
- name: Rustfmt tests
149-
run: rustfmt --check tests/ui/**/*.rs
159+
- name: Rustfmt compiletests
160+
run: shopt -s globstar && rustfmt --check tests/compiletests/ui/**/*.rs
161+
- name: Rustfmt difftests
162+
run: cargo fmt --check --all --manifest-path tests/difftests/tests/Cargo.toml
150163
- name: Check docs are valid
151164
run: RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps
152165
- name: Check docs for `spirv-std` and `spirv-builder` on stable (for docs.rs)

Cargo.lock

Lines changed: 80 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ members = [
2424
"crates/spirv-std/shared",
2525
"crates/spirv-std/macros",
2626

27-
"tests",
28-
"tests/deps-helper",
27+
"tests/compiletests",
28+
"tests/compiletests/deps-helper",
29+
"tests/difftests/bin",
30+
"tests/difftests/lib",
2931
]
3032

3133
[workspace.package]

deny.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ skip-tree = [
6060
{ name = "num_cpus", version = "=1.16.0", depth = 2 },
6161
# HACK(LegNeato) `tracing-tree` uses newer dependencies of `tracing`.
6262
{ name = "tracing-tree", version = "=0.3.1" },
63+
# HACK(LegNeato) `thorin` has not yet released the version that bumps this.
64+
{ name = "gimli", version = "=0.30.0" },
6365
]
6466

6567

docs/src/testing.md

Lines changed: 8 additions & 4 deletions
File renamed without changes.

tests/src/main.rs renamed to tests/compiletests/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const SPIRV_TARGET_PREFIX: &str = "spirv-unknown-";
3131

3232
fn target_spec_json(target: &str) -> String {
3333
format!(
34-
"{}/../crates/spirv-builder/target-specs/{target}.json",
34+
"{}/../../crates/spirv-builder/target-specs/{target}.json",
3535
env!("CARGO_MANIFEST_DIR")
3636
)
3737
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)