Skip to content

Commit

Permalink
test: list arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Aug 5, 2023
1 parent da6509b commit ee5aeef
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/fixtures/append-script-args/list-args.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -o errexit -o nounset
for arg in "$@"; do
echo "$arg"
done
5 changes: 5 additions & 0 deletions tests/fixtures/append-script-args/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"list-args": "sh list-args.sh"
}
}
5 changes: 5 additions & 0 deletions tests/fixtures/append-script-args/stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
foo
bar
hello world
! !@
abc def ghi
24 changes: 24 additions & 0 deletions tests/test_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@ fn run_script() {
));
}

#[test]
fn append_script_args() {
let temp_dir = tempdir().unwrap();
let tree = MergeableFileSystemTree::<&str, &str>::from(dir! {
"package.json" => file!(include_str!("fixtures/append-script-args/package.json")),
"list-args.sh" => file!(include_str!("fixtures/append-script-args/list-args.sh")),
});
tree.build(&temp_dir).unwrap();

Command::cargo_bin("pn")
.unwrap()
.current_dir(&temp_dir)
.arg("run")
.arg("list-args")
.arg("foo")
.arg("bar")
.arg("hello world")
.arg("! !@")
.arg("abc def ghi")
.assert()
.success()
.stdout(include_str!("fixtures/append-script-args/stdout.txt"));
}

#[test]
fn run_from_workspace_root() {
let temp_dir = tempdir().unwrap();
Expand Down

0 comments on commit ee5aeef

Please sign in to comment.