tests: Validate WGSL output
WGSL was the only format that wasn't being validated for our E2E tests, and this meant that WGSL backend bugs were sometimes going unnoticed. This change uses Tint's WGSL reader to validate the WGSL output. Change-Id: I7d9e1c22feda530e7ba594725f21e576cf928647 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80961 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
7161ae55c2
commit
0f56ed9759
|
@ -623,7 +623,24 @@ bool GenerateWgsl(const tint::Program* program, const Options& options) {
|
|||
return false;
|
||||
}
|
||||
|
||||
return WriteFile(options.output_file, "w", result.wgsl);
|
||||
if (!WriteFile(options.output_file, "w", result.wgsl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.validate) {
|
||||
// Attempt to re-parse the output program with Tint's WGSL reader.
|
||||
auto source = std::make_unique<tint::Source::File>(options.input_filename,
|
||||
result.wgsl);
|
||||
auto reparsed_program = tint::reader::wgsl::Parse(source.get());
|
||||
if (!reparsed_program.IsValid()) {
|
||||
auto diag_printer = tint::diag::Printer::create(stderr, true);
|
||||
tint::diag::Formatter diag_formatter;
|
||||
diag_formatter.format(reparsed_program.Diagnostics(), diag_printer.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
(void)program;
|
||||
(void)options;
|
||||
|
|
Loading…
Reference in New Issue