Skip to content

Commit

Permalink
ci: Add support for test kinds (for now, only render), mark those a…
Browse files Browse the repository at this point in the history
…s heavy for nextest
  • Loading branch information
torokati44 committed Aug 20, 2024
1 parent c6947b6 commit 007df30
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# TODO: Figure out why this specific test is flaky on CI, fix it, then delete this file.
# This is needed so we don't try to run too many visual tests at the same time,
# as they tend to crash on GitHub Actions runners - maybe due to not enough memory.
[[profile.ci.overrides]]
filter = "test(avm2/pixelbender_shaderdata)"
retries = 3
filter = "test(/^\\[render\\] /)"
threads-required = 3
4 changes: 4 additions & 0 deletions tests/framework/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ impl PlayerOptions {
})
}

pub fn needs_renderer(&self) -> bool {
self.with_renderer.is_some()
}

pub fn create_renderer(
&self,
environment: &impl Environment,
Expand Down
28 changes: 28 additions & 0 deletions tests/framework/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ pub struct Font {
pub italic: bool,
}

#[derive(Clone, Copy)]
pub enum TestKind {
Render,
}

impl TestKind {
pub fn name(self) -> &'static str {
match self {
TestKind::Render => "render",
}
}

pub fn ord(kind: &str) -> impl Ord {
match kind {
"render" => 0,
_ => 1,
}
}
}

pub struct Test {
pub options: TestOptions,
pub swf_path: VfsPath,
Expand Down Expand Up @@ -43,6 +63,14 @@ impl Test {
})
}

pub fn kind(&self) -> Option<TestKind> {
if self.options.player_options.needs_renderer() {
Some(TestKind::Render)
} else {
None
}
}

pub fn create_test_runner(&self, environment: &impl Environment) -> Result<TestRunner> {
let movie = self.movie()?;
let viewport_dimensions = self.options.player_options.viewport_dimensions(&movie);
Expand Down
4 changes: 4 additions & 0 deletions tests/tests/regression_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ fn run_test(args: &Arguments, file: &Path, name: &str) -> Trial {
.unwrap();

let ignore = !test.should_run(!args.list, &NativeEnvironment);
let kind = test.kind();

let mut trial = Trial::test(test.name.to_string(), move || {
let test = AssertUnwindSafe(test);
Expand Down Expand Up @@ -197,6 +198,9 @@ fn run_test(args: &Arguments, file: &Path, name: &str) -> Trial {
}
}
});
if let Some(kind) = kind {
trial = trial.with_kind(kind.name());
}
if ignore {
trial = trial.with_ignored_flag(true);
}
Expand Down

0 comments on commit 007df30

Please sign in to comment.