mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 06:30:08 +02:00
Support running batch files without typing their extension (#6278)
* Support running batch files without typing their extension * suppress warning
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::fs::Stub::{EmptyFile, FileWithContent};
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
@ -259,3 +259,60 @@ fn single_quote_does_not_expand_path_glob_windows() {
|
||||
assert!(actual.out.contains("D&D_volume_2.txt"));
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn can_run_batch_files() {
|
||||
Playground::setup("run a Windows batch file", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"foo.cmd",
|
||||
r#"
|
||||
@echo off
|
||||
echo Hello World
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline("foo.cmd"));
|
||||
assert!(actual.out.contains("Hello World"));
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn can_run_batch_files_without_cmd_extension() {
|
||||
Playground::setup(
|
||||
"run a Windows batch file without specifying the extension",
|
||||
|dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"foo.cmd",
|
||||
r#"
|
||||
@echo off
|
||||
echo Hello World
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline("foo"));
|
||||
assert!(actual.out.contains("Hello World"));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn can_run_batch_files_without_bat_extension() {
|
||||
Playground::setup(
|
||||
"run a Windows batch file without specifying the extension",
|
||||
|dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"foo.bat",
|
||||
r#"
|
||||
@echo off
|
||||
echo Hello World
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline("foo"));
|
||||
assert!(actual.out.contains("Hello World"));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user