[spirv-reader] Fix test helper failure returns

Use an explicit `Result` object rather than a string that can either
mean success of failure. There are situations where a failure message
might contain the expected success string (e.g. IR validation
disassembly), which trips up the substring matcher.

Bug: tint:1907
Change-Id: Ie91090e6f681ed170bb6d3fb4b50b676226e3095
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/170000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/lang/spirv/reader/parser/helper_test.h b/src/tint/lang/spirv/reader/parser/helper_test.h
index 489484e..decab00 100644
--- a/src/tint/lang/spirv/reader/parser/helper_test.h
+++ b/src/tint/lang/spirv/reader/parser/helper_test.h
@@ -44,10 +44,12 @@
 
 // Helper macro to run the parser and compare the disassembled IR to a string.
 // Automatically prefixes the IR disassembly with a newline to improve formatting of tests.
-#define EXPECT_IR(asm, ir)                               \
-    do {                                                 \
-        auto got = "\n" + Run(asm);                      \
-        ASSERT_THAT(got, testing::HasSubstr(ir)) << got; \
+#define EXPECT_IR(asm, ir)                                           \
+    do {                                                             \
+        auto result = Run(asm);                                      \
+        ASSERT_EQ(result, Success) << result.Failure().reason.str(); \
+        auto got = "\n" + result.Get();                              \
+        ASSERT_THAT(got, testing::HasSubstr(ir)) << got;             \
     } while (false)
 
 /// Base helper class for testing the SPIR-V parser implementation.
@@ -73,8 +75,8 @@
 
     /// Run the parser on a SPIR-V module and return the Tint IR or an error string.
     /// @param spirv_asm the SPIR-V assembly to parse
-    /// @returns the disassembled Tint IR
-    std::string Run(std::string spirv_asm) {
+    /// @returns the disassembled Tint IR or an error
+    Result<std::string> Run(std::string spirv_asm) {
         // Assemble the SPIR-V input.
         auto binary = Assemble(spirv_asm);
         if (binary != Success) {
@@ -84,13 +86,13 @@
         // Parse the SPIR-V to produce an IR module.
         auto parsed = Parse(Slice(binary.Get().data(), binary.Get().size()));
         if (parsed != Success) {
-            return parsed.Failure().reason.str();
+            return parsed.Failure();
         }
 
         // Validate the IR module.
         auto validated = core::ir::Validate(parsed.Get());
         if (validated != Success) {
-            return validated.Failure().reason.str();
+            return validated.Failure();
         }
 
         // Return the disassembled IR module.