Skip to content

Commit

Permalink
Test --web-bundle overrides for v1 & v2 CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
bryango committed Dec 23, 2023
1 parent 053695a commit 21069ff
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/bin/tectonic/v2cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
89 changes: 87 additions & 2 deletions tests/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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 {
Expand All @@ -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() {
Expand Down

0 comments on commit 21069ff

Please sign in to comment.