Skip to content

Commit

Permalink
fix(cli): Ensure new tests can't have invalid components
Browse files Browse the repository at this point in the history
Previously a freshly created test could contain a component which would later be
ignored by the collector, leading to the creation of tests which are neither
collectable, nor stable, as deletions of temporary directories could destroy
them. This avoids the creation of such tests.
  • Loading branch information
tingerrr committed Aug 11, 2024
1 parent 62a6805 commit cc755c0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/typst-test-cli/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,14 @@ impl Project {
let _span = tracing::debug_span!("creating test", test = ?id, ?kind, ?use_template);

if self.tests.contains_key(&id) {
anyhow::bail!("Test '{id}' alreayd exists");
anyhow::bail!("Test '{id}' already exists");
}

if let Some(reserved) = id
.components()
.find(|comp| self.resolver.reserved().contains(comp))
{
anyhow::bail!("Test contains reserved fragment: '{reserved}'")
}

let source = match (use_template, &self.template) {
Expand Down

0 comments on commit cc755c0

Please sign in to comment.