summaryrefslogtreecommitdiff
path: root/tests/src/args.rs
diff options
context:
space:
mode:
authorLeedehai <18319900+Leedehai@users.noreply.github.com>2024-04-18 08:20:42 -0400
committerGitHub <noreply@github.com>2024-04-18 12:20:42 +0000
commit1b091d628da58107134a5b4e04ec063e3c0be705 (patch)
treef1488776ec86e761a71de5b98fedfb5c68093913 /tests/src/args.rs
parentc5c73ec9315b8148e851693ffa279c75a97982d3 (diff)
Enhance the test runner: regex, --list, --path (#3945)
Diffstat (limited to 'tests/src/args.rs')
-rw-r--r--tests/src/args.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/src/args.rs b/tests/src/args.rs
index fcd4ead1..33935edf 100644
--- a/tests/src/args.rs
+++ b/tests/src/args.rs
@@ -1,19 +1,30 @@
+use std::path::PathBuf;
+
use clap::{Parser, Subcommand};
+use regex::Regex;
/// Typst's test runner.
#[derive(Debug, Clone, Parser)]
+#[command(bin_name = "cargo test --workspace --test tests --")]
#[clap(name = "typst-test", author)]
pub struct CliArguments {
/// The command to run.
#[command(subcommand)]
pub command: Option<Command>,
- /// All the tests that contain the filter string will be run.
- pub filter: Vec<String>,
- /// Runs only the tests with the exact specified `filter` names.
+ /// All the tests whose names match the test name pattern will be run.
+ #[arg(value_parser = Regex::new)]
+ pub pattern: Vec<Regex>,
+ /// Restricts test selection within the given path.
+ #[arg(short, long, value_parser = |s: &str| PathBuf::from(s).canonicalize())]
+ pub path: Vec<PathBuf>,
+ /// Only selects the test that matches with the test name verbatim.
#[arg(short, long)]
pub exact: bool,
- /// Whether to update the reference images of non-passing tests.
- #[arg(short, long)]
+ /// Lists what tests will be run, without actually running them.
+ #[arg(long, group = "action")]
+ pub list: bool,
+ /// Updates the reference images of non-passing tests.
+ #[arg(short, long, group = "action")]
pub update: bool,
/// The scaling factor to render the output image with.
///
@@ -26,7 +37,7 @@ pub struct CliArguments {
/// Exports SVG outputs into the artifact store.
#[arg(long)]
pub svg: bool,
- /// Whether to display the syntax tree.
+ /// Displays the syntax tree.
#[arg(long)]
pub syntax: bool,
/// Prevents the terminal from being cleared of test names.