summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-05-08 13:01:08 +0200
committerGitHub <noreply@github.com>2024-05-08 11:01:08 +0000
commitbe12762d942e978ddf2e0ac5c34125264ab483b7 (patch)
treeb800aea0713768859ec5a65dab4d94372c579ff5 /tests
parent4bca472210d1863fcb638e9b641ddc2a1e9b1515 (diff)
Run PDF and SVG export in CI (#4097)
Diffstat (limited to 'tests')
-rw-r--r--tests/src/args.rs22
-rw-r--r--tests/src/run.rs4
2 files changed, 22 insertions, 4 deletions
diff --git a/tests/src/args.rs b/tests/src/args.rs
index 33935edf..ca0ee73c 100644
--- a/tests/src/args.rs
+++ b/tests/src/args.rs
@@ -31,10 +31,16 @@ pub struct CliArguments {
/// Does not affect the comparison or the reference image.
#[arg(short, long, default_value_t = 1.0)]
pub scale: f32,
- /// Exports PDF outputs into the artifact store.
+ /// Whether to run the tests in extended mode, including PDF and SVG
+ /// export.
+ ///
+ /// This is used in CI.
+ #[arg(long, env = "TYPST_TESTS_EXTENDED")]
+ pub extended: bool,
+ /// Runs PDF export.
#[arg(long)]
pub pdf: bool,
- /// Exports SVG outputs into the artifact store.
+ /// Runs SVG export.
#[arg(long)]
pub svg: bool,
/// Displays the syntax tree.
@@ -48,6 +54,18 @@ pub struct CliArguments {
pub num_threads: Option<usize>,
}
+impl CliArguments {
+ /// Whether to run PDF export.
+ pub fn pdf(&self) -> bool {
+ self.pdf || self.extended
+ }
+
+ /// Whether to run SVG export.
+ pub fn svg(&self) -> bool {
+ self.svg || self.extended
+ }
+}
+
/// What to do.
#[derive(Debug, Clone, Subcommand)]
#[command()]
diff --git a/tests/src/run.rs b/tests/src/run.rs
index f797147f..d0d86ea6 100644
--- a/tests/src/run.rs
+++ b/tests/src/run.rs
@@ -174,14 +174,14 @@ impl<'a> Runner<'a> {
std::fs::write(&live_path, data).unwrap();
// Write PDF if requested.
- if crate::ARGS.pdf {
+ if crate::ARGS.pdf() {
let pdf_path = format!("{}/pdf/{}.pdf", crate::STORE_PATH, self.test.name);
let pdf = typst_pdf::pdf(document, Smart::Auto, None);
std::fs::write(pdf_path, pdf).unwrap();
}
// Write SVG if requested.
- if crate::ARGS.svg {
+ if crate::ARGS.svg() {
let svg_path = format!("{}/svg/{}.svg", crate::STORE_PATH, self.test.name);
let svg = typst_svg::svg_merged(document, Abs::pt(5.0));
std::fs::write(svg_path, svg).unwrap();