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 6632cb3 commit 61eb46a
Showing 1 changed file with 107 additions and 3 deletions.
110 changes: 107 additions & 3 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 & `-X compile`
#[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,20 +654,123 @@ fn web_bundle_flag() {
);
error_or_panic(&output);

// test with a good bundle
let valid_args: Vec<Vec<&str>> = vec![
// test with a good bundle (override)
let mut 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(),
];

// test `-X compile`
#[cfg(feature = "serialization")]
valid_args.push(
[
&arg_bad_bundle[..],
&arg_bad_bundle[..],
&["-X"],
&arg_bad_bundle[..],
&["compile"],
&arg_bad_bundle[..],
&[fmt_arg],
&arg_bad_bundle[..],
&[filename],
&arg_bad_bundle[..],
&arg_good_bundle[..],
]
.concat(),
);

for args in valid_args {
let output = run_tectonic(&temppath, &args);
success_or_panic(&output);
}
}

/// 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 61eb46a

Please sign in to comment.