Skip to content

Commit

Permalink
Merge pull request #40 from ErichDonGubler/refac-parsing-to-traits
Browse files Browse the repository at this point in the history
Refactor `whippit` to be a set of `traits` instead of `struct`s
  • Loading branch information
ErichDonGubler authored Oct 31, 2023
2 parents e0ed12a + dbe8ddb commit 954abed
Show file tree
Hide file tree
Showing 6 changed files with 637 additions and 450 deletions.
17 changes: 6 additions & 11 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod metadata;
mod shared;

use self::{
metadata::{AnalyzeableProps, Platform, SubtestOutcome, Test, TestOutcome},
metadata::{AnalyzeableProps, File, Platform, Subtest, SubtestOutcome, Test, TestOutcome},
shared::{Expectation, MaybeCollapsed},
};

Expand All @@ -24,10 +24,7 @@ use path_dsl::path;

use regex::Regex;
use wax::Glob;
use whippit::{
metadata::{SectionHeader, Subtest},
reexport::chumsky::prelude::Rich,
};
use whippit::{metadata::SectionHeader, reexport::chumsky::prelude::Rich};

#[derive(Debug, Parser)]
#[command(about, version)]
Expand Down Expand Up @@ -186,7 +183,7 @@ fn run(cli: Cli) -> ExitCode {
struct TaggedTest {
#[allow(unused)]
orig_path: Arc<PathBuf>,
inner: metadata::Test,
inner: Test,
}
let tests_by_name = {
let mut found_parse_err = false;
Expand All @@ -200,8 +197,8 @@ fn run(cli: Cli) -> ExitCode {
match chumsky::Parser::parse(&metadata::File::parser(), file_contents)
.into_result()
{
Ok(metadata::File { tests }) => Some(tests.into_iter().map(|inner| {
let SectionHeader(name) = &inner.name;
Ok(File { tests }) => Some(tests.into_iter().map(|(name, inner)| {
let SectionHeader(name) = &name;
(
SectionHeader(
name.strip_prefix("cts.https.html?q=").unwrap().to_owned(),
Expand Down Expand Up @@ -300,17 +297,15 @@ fn run(cli: Cli) -> ExitCode {
}

let mut analysis = Analysis::default();
for (_nice_name, test) in tests_by_name {
for (SectionHeader(test_name), test) in tests_by_name {
let TaggedTest {
orig_path: _,
inner: test,
} = test;

let Test {
name: SectionHeader(test_name),
properties,
subtests,
..
} = test;

let AnalyzeableProps {
Expand Down
Loading

0 comments on commit 954abed

Please sign in to comment.