Fix IRToProgramRoundTripTest for invalid WGSL
The `IRToProgramRoundTripTest` `RUN_TEST` method only fails if there is
an `err` string set on the result. In the case of `WGSLToIR` failing we
would just return an empty `result` and not set the error. This means,
if the WGSL if invalid, the test passes, even though it hasn't run.
This CL fixes the `result` to set the error string and then fixes up the
various tests which fail because the WGSL was invalid.
Change-Id: I39f9d4b8652a55321d7aa49aa1b5240990323de9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/243574
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/wgsl/ir_roundtrip_test.cc b/src/tint/lang/wgsl/ir_roundtrip_test.cc
index 7f7771b..afe718d 100644
--- a/src/tint/lang/wgsl/ir_roundtrip_test.cc
+++ b/src/tint/lang/wgsl/ir_roundtrip_test.cc
@@ -70,6 +70,7 @@
Source::File file("test.wgsl", std::string(input));
auto ir_module = wgsl::reader::WgslToIR(&file, options);
if (ir_module != Success) {
+ result.err = ir_module.Failure().reason;
return result;
}
@@ -261,7 +262,9 @@
struct S {
a : i32,
@location(0u) @blend_src(0u)
- b : u32,
+ b0 : u32,
+ @location(0u) @blend_src(1u)
+ b1 : u32,
c : f32,
}
@@ -2005,6 +2008,8 @@
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_array_Zero) {
RUN_TEST(R"(
var<private> v : array<i32, 4u> = array<i32, 4u>(0i, 0i, 0i, 0i);
+)",
+ R"(
var<private> v : array<i32, 4u> = array<i32, 4u>();
)");
}
@@ -2086,8 +2091,10 @@
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_vec3f_Zero) {
RUN_TEST(R"(
-var<private> v : vec3<f32> = vec3<f32>(0f);",
- "var<private> v : vec3<f32> = vec3<f32>();
+var<private> v : vec3<f32> = vec3<f32>(0f);
+)",
+ R"(
+var<private> v : vec3<f32> = vec3<f32>();
)");
}
@@ -2112,6 +2119,8 @@
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_Scalars_SameValue) {
RUN_TEST(R"(
var<private> v : mat2x3<f32> = mat2x3<f32>(4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f);
+)",
+ R"(
var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f), vec3<f32>(4.0f));
)");
}
@@ -2119,6 +2128,8 @@
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_Scalars) {
RUN_TEST(R"(
var<private> v : mat2x3<f32> = mat2x3<f32>(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);
+)",
+ R"(
var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(4.0f, 5.0f, 6.0f));
)");
}
@@ -2133,6 +2144,8 @@
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_Columns_SameValue) {
RUN_TEST(R"(
var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f, 4.0f, 4.0f), vec3<f32>(4.0f, 4.0f, 4.0f));
+)",
+ R"(
var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f), vec3<f32>(4.0f));
)");
}
@@ -3434,7 +3447,14 @@
enable chromium_experimental_subgroup_matrix;
fn f() {
- var m = subgroup_matrix_left<f32, 8, 8>>();
+ var m = subgroup_matrix_left<f32, 8, 8>();
+}
+)",
+ R"(
+enable chromium_experimental_subgroup_matrix;
+
+fn f() {
+ var m : subgroup_matrix_left<f32, 8, 8> = subgroup_matrix_left<f32, 8, 8>();
}
)");
}