Skip to content

Commit

Permalink
fix(wpt): run async tests and collect results
Browse files Browse the repository at this point in the history
  • Loading branch information
huancheng-trili committed Jan 7, 2025
1 parent 373ec79 commit 94cfb5c
Show file tree
Hide file tree
Showing 3 changed files with 367 additions and 42 deletions.
10 changes: 9 additions & 1 deletion crates/jstz_api/tests/wpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ pub struct TestsResult {
#[derive(Default, Debug, Trace, Finalize, JsData)]
pub struct TestHarnessReport {
#[unsafe_ignore_trace]
// `status` is an Option because it is set at the end of a test suite
// and we need a placeholder for it before that.
status: Option<WptTestStatus>,
#[unsafe_ignore_trace]
subtests: Vec<WptSubtest>,
Expand Down Expand Up @@ -282,6 +284,9 @@ pub fn run_wpt_test_harness(bundle: &Bundle) -> JsResult<Box<TestHarnessReport>>
}
}

// Execute promises after all sync tests have completed after `eval` returns
rt.run_jobs();

// Return the test harness report

let test_harness_report = {
Expand All @@ -305,7 +310,10 @@ fn run_wpt_test(
return Ok(WptReportTest::new(WptTestStatus::Err, vec![]));
};

let status = report.status.clone().unwrap_or(WptTestStatus::Null);
// It should be safe to unwrap here because each test suite should have a
// status code attached after it completes. If unwrap fails, it means something
// is wrong and we should fix that
let status = report.status.clone().unwrap();

let subtests = report.subtests.clone();

Expand Down
Loading

0 comments on commit 94cfb5c

Please sign in to comment.