Skip to content

Commit a4d6e33

Browse files
author
Mingshen Sun
committed
tests: revert setting the default dir but provide a macro to get fixtures directory
1 parent abdb172 commit a4d6e33

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

tests/macros.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,20 @@ macro_rules! util_name {
9191

9292
#[macro_export]
9393
macro_rules! new_cli {
94-
() => {{
95-
use std::env;
96-
let mut fixture_path = env::current_dir().unwrap();
97-
fixture_path.push("tests");
98-
fixture_path.push("fixtures");
99-
fixture_path.push(util_name!());
94+
() => {
10095
assert_cli::Assert::main_binary()
10196
.with_args(&[util_name!()])
102-
.current_dir(fixture_path)
97+
};
98+
}
99+
100+
#[macro_export]
101+
macro_rules! fixtures_path {
102+
() => {{
103+
use std::env;
104+
let mut path = env::current_dir().unwrap();
105+
path.push("tests/fixtures");
106+
path.push(util_name!());
107+
path
103108
}};
104109
}
105110

tests/posix/test_cat.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use assert_cli;
3636
#[test]
3737
fn test_output_multi_files_print_all_chars() {
3838
new_cli!()
39+
.current_dir(fixtures_path!())
3940
.with_args(&["alpha.txt", "256.txt", "-A", "-n"])
4041
.succeeds()
4142
.and()
@@ -57,6 +58,7 @@ fn test_output_multi_files_print_all_chars() {
5758
#[test]
5859
fn test_numbered_lines_no_trailing_newline() {
5960
new_cli!()
61+
.current_dir(fixtures_path!())
6062
.with_args(&["nonewline.txt", "alpha.txt", "-n"])
6163
.succeeds()
6264
.and()

0 commit comments

Comments
 (0)