|
6 | 6 |
|
7 | 7 | mod common;
|
8 | 8 |
|
9 |
| -use std::process::Command; |
| 9 | +use std::{fs::File, io, process::Command}; |
10 | 10 |
|
11 | 11 | use assert_cmd::{assert::OutputAssertExt, cargo::CommandCargoExt};
|
12 |
| -use rstest::rstest; |
13 |
| - |
14 |
| -use crate::common::test_helpers::fix_up_slashes; |
| 12 | +use rstest::{fixture, rstest}; |
| 13 | + |
| 14 | +#[fixture] |
| 15 | +fn add_special_files() -> io::Result<()> { |
| 16 | + File::create("test_data/db/abc def")?; |
| 17 | + File::create("test_data/db/abc\ndef")?; |
| 18 | + File::create("test_data/db/✨sparkles✨")?; |
| 19 | + Ok(()) |
| 20 | +} |
15 | 21 |
|
16 | 22 | #[cfg(not(windows))]
|
17 | 23 | const DB_FLAG: &str = "--database=test_data_db";
|
@@ -76,14 +82,16 @@ fn test_locate_non_existing() {
|
76 | 82 | .failure();
|
77 | 83 | }
|
78 | 84 |
|
79 |
| -#[test] |
| 85 | +#[rstest] |
80 | 86 | #[cfg(not(windows))]
|
81 |
| -fn test_locate_statistics() { |
82 |
| - Command::cargo_bin("locate") |
83 |
| - .expect("couldn't find locate binary") |
84 |
| - .args(["abbbc", "--statistics", DB_FLAG]) |
85 |
| - .assert() |
86 |
| - .success(); |
| 87 | +fn test_locate_statistics(add_special_files: io::Result<()>) { |
| 88 | + if add_special_files.is_ok() { |
| 89 | + Command::cargo_bin("locate") |
| 90 | + .expect("couldn't find locate binary") |
| 91 | + .args(["abbbc", "--statistics", DB_FLAG]) |
| 92 | + .assert() |
| 93 | + .success(); |
| 94 | + } |
87 | 95 | }
|
88 | 96 |
|
89 | 97 | #[rstest]
|
@@ -125,15 +133,12 @@ fn test_locate_all_regex() {
|
125 | 133 | .success();
|
126 | 134 | }
|
127 | 135 |
|
128 |
| -#[test] |
| 136 | +#[rstest] |
129 | 137 | #[cfg(not(windows))]
|
130 |
| -fn test_updatedb() { |
| 138 | +fn test_updatedb(_add_special_files: io::Result<()>) { |
131 | 139 | Command::cargo_bin("updatedb")
|
132 | 140 | .expect("couldn't find updatedb binary")
|
133 |
| - .args([ |
134 |
| - fix_up_slashes("--localpaths=./test_data"), |
135 |
| - fix_up_slashes("--output=/dev/null"), |
136 |
| - ]) |
| 141 | + .args(["--localpaths=./test_data", "--output=/dev/null"]) |
137 | 142 | .assert()
|
138 | 143 | .success();
|
139 | 144 | }
|
0 commit comments