From 21069ff292d1dd5cdaf56e1eab46fb3d2d1f982c Mon Sep 17 00:00:00 2001 From: Bryan Lai <bryanlais@gmail.com> Date: Sat, 23 Dec 2023 11:00:12 +0800 Subject: [PATCH] Test `--web-bundle` overrides for v1 & v2 CLI --- src/bin/tectonic/v2cli.rs | 3 +- tests/executable.rs | 89 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/src/bin/tectonic/v2cli.rs b/src/bin/tectonic/v2cli.rs index 475da314e..2e00c47d9 100644 --- a/src/bin/tectonic/v2cli.rs +++ b/src/bin/tectonic/v2cli.rs @@ -278,9 +278,10 @@ impl BuildCommand { web_bundle: Option<String>, ) -> Result<i32> { // `--web-bundle` is not actually used for `-X build`, - // so inform the user instead of silently ignore. + // so inform the user instead of ignoring silently. if let Some(url) = web_bundle { tt_note!(status, "--web-bundle {} ignored", &url); + tt_note!(status, "using workspace bundle configuration"); } let ws = Workspace::open_from_environment()?; let doc = ws.first_document(); diff --git a/tests/executable.rs b/tests/executable.rs index eabad0d84..4fc02f850 100644 --- a/tests/executable.rs +++ b/tests/executable.rs @@ -636,8 +636,9 @@ fn stdin_content() { success_or_panic(&output); } +/// Test various web bundle overrides for the v1 CLI #[test] -fn web_bundle_flag() { +fn web_bundle_overrides() { let filename = "subdirectory/content/1.tex"; let fmt_arg: &str = &get_plain_format_arg(); let tempdir = setup_and_copy_files(&[filename]); @@ -653,12 +654,32 @@ fn web_bundle_flag() { ); error_or_panic(&output); - // test with a good bundle + // test with a good bundle (override) let valid_args: Vec<Vec<&str>> = vec![ // different positions [&arg_good_bundle[..], &[fmt_arg, filename]].concat(), [&[fmt_arg], &arg_good_bundle[..], &[filename]].concat(), [&[fmt_arg], &[filename], &arg_good_bundle[..]].concat(), + // overriding vendor presets + [ + &arg_bad_bundle[..], + &arg_good_bundle[..], + &[fmt_arg], + &[filename], + ] + .concat(), + // stress test + [ + &arg_bad_bundle[..], + &arg_bad_bundle[..], + &[fmt_arg], + &arg_bad_bundle[..], + &arg_bad_bundle[..], + &[filename], + &arg_bad_bundle[..], + &arg_good_bundle[..], + ] + .concat(), ]; for args in valid_args { @@ -667,6 +688,70 @@ fn web_bundle_flag() { } } +/// Test various web bundle overrides for the v2 CLI +#[cfg(feature = "serialization")] +#[test] +fn v2_bundle_overrides() { + let arg_bad_bundle = ["--web-bundle", "bad-bundle"]; + let arg_good_bundle = ["--web-bundle", "test-bundle://"]; + + // test `-X command` + for command in ["new", "init"] { + // test with a bad bundle + let tempdir = setup_and_copy_files(&[]); + let temppath = tempdir.path().to_owned(); + let output = run_tectonic(&temppath, &[&arg_bad_bundle[..], &["-X", command]].concat()); + error_or_panic(&output); + + // test with a good bundle (override) + let valid_args: Vec<Vec<&str>> = vec![ + // different positions + [&arg_good_bundle[..], &["-X", command]].concat(), + [&["-X"], &arg_good_bundle[..], &[command]].concat(), + [&["-X", command], &arg_good_bundle[..]].concat(), + // overriding vendor presets + [&arg_bad_bundle[..], &arg_good_bundle[..], &["-X", command]].concat(), + [ + &arg_bad_bundle[..], + &["-X"], + &arg_good_bundle[..], + &[command], + ] + .concat(), + [&arg_bad_bundle[..], &["-X", command], &arg_good_bundle[..]].concat(), + // stress test + [ + &arg_bad_bundle[..], + &arg_bad_bundle[..], + &["-X"], + &arg_bad_bundle[..], + &arg_bad_bundle[..], + &[command], + &arg_bad_bundle[..], + &arg_good_bundle[..], + ] + .concat(), + ]; + + for args in valid_args { + let tempdir = setup_and_copy_files(&[]); + let temppath = tempdir.path().to_owned(); + let output = run_tectonic(&temppath, &args); + success_or_panic(&output); + } + } + + // test `-X build` + let (_tempdir, temppath) = setup_v2(); + + // `--web-bundle` is ignored + let output = run_tectonic( + &temppath, + &[&arg_bad_bundle[..], &["-X"], &["build"]].concat(), + ); + success_or_panic(&output); +} + #[cfg(feature = "serialization")] #[test] fn v2_build_basic() {