@@ -34,6 +34,18 @@ fn get_mocked_pagers_dir() -> PathBuf {
3434 .join("mocked-pagers")
3535}
3636
37+/// On Unix: 'most' -> 'most'
38+/// On Windows: 'most' -> 'most.bat'
39+fn mocked_pager(base: &str) -> String {
40+ if cfg!(windows) {
41+ let mut str = String::from(base);
42+ str.push_str(".bat");
43+ str
44+ } else {
45+ String::from(base)
46+ }
47+}
48+
3749/// Prepends a directory to the PATH environment variable
3850/// Returns the original value for later restoration
3951fn prepend_dir_to_path_env_var(dir: PathBuf) -> String {
@@ -64,14 +76,14 @@ fn with_mocked_versions_of_more_and_most_in_path(actual_test: fn()) {
6476 let original_path = prepend_dir_to_path_env_var(get_mocked_pagers_dir());
6577
6678 // Make sure our own variants of 'more' and 'most' is used
67− Command::new("more")
79+ Command::new(mocked_pager("more"))
6880 .assert()
6981 .success()
70− .stdout("I am more\n");
71− Command::new("most")
82+ .stdout(predicate::str::contains("I am more"));
83+ Command::new(mocked_pager("most"))
7284 .assert()
7385 .success()
74− .stdout("I am most\n");
86+ .stdout(predicate::str::contains("I am most"));
7587
7688 // Now run the actual test
7789 actual_test();
@@ -478,9 +490,9 @@ fn pager_value_bat() {
478490#[serial] // Because of PATH
479491fn pager_most_from_pager_env_var() {
480492 with_mocked_versions_of_more_and_most_in_path(|| {
481− // If the output is not "I am most\n" then we know 'most' is not used
493+ // If the output is not "I am most" then we know 'most' is not used
482494 bat()
483− .env("PAGER", "most")
495+ .env("PAGER", mocked_pager("most"))
484496 .arg("--paging=always")
485497 .arg("test.txt")
486498 .assert()
@@ -496,12 +508,12 @@ fn pager_most_from_pager_env_var() {
496508fn pager_most_from_bat_pager_env_var() {
497509 with_mocked_versions_of_more_and_most_in_path(|| {
498510 bat()
499− .env("BAT_PAGER", "most")
511+ .env("BAT_PAGER", mocked_pager("most"))
500512 .arg("--paging=always")
501513 .arg("test.txt")
502514 .assert()
503515 .success()
504− .stdout(predicate::eq("I am most\n").normalize());
516+ .stdout(predicate::str::contains("I am most"));
505517 });
506518}
507519
@@ -512,11 +524,11 @@ fn pager_most_from_pager_arg() {
512524 with_mocked_versions_of_more_and_most_in_path(|| {
513525 bat()
514526 .arg("--paging=always")
515− .arg("--pager=most")
527+ .arg(format!("--pager={}", mocked_pager("most")))
516528 .arg("test.txt")
517529 .assert()
518530 .success()
519− .stdout(predicate::eq("I am most\n").normalize());
531+ .stdout(predicate::str::contains("I am most"));
520532 });
521533}
522534
@@ -526,7 +538,7 @@ fn pager_most_from_pager_arg() {
526538fn pager_most_with_arg() {
527539 with_mocked_versions_of_more_and_most_in_path(|| {
528540 bat()
529− .env("PAGER", "most -w")
541+ .env("PAGER", format!("{} -w", mocked_pager("most")))
530542 .arg("--paging=always")
531543 .arg("test.txt")
532544 .assert()
@@ -541,7 +553,7 @@ fn pager_most_with_arg() {
541553fn pager_more() {
542554 with_mocked_versions_of_more_and_most_in_path(|| {
543555 bat()
544− .env("PAGER", "more")
556+ .env("PAGER", mocked_pager("more"))
545557 .arg("--paging=always")
546558 .arg("test.txt")
547559 .assert()