summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2020-04-21 16:02:28 +0200
committersharkdp <davidpeter@web.de>2020-04-21 16:02:28 +0200
commit5449472f15e4b5f063f9933fe426c8d3138bfa45 (patch)
treec603c55138ef0a7d0273f7a7851499018228597a
parent82e20bfe14b05c3b3224cb1feb529c655a1e74e3 (diff)
Remove invalid UTF-8 file from repo, use temp file instead
-rw-r--r--tests/examples/test-invalid-utf8-Ã(.rs4
-rw-r--r--tests/integration_tests.rs18
2 files changed, 16 insertions, 6 deletions
diff --git a/tests/examples/test-invalid-utf8-Ã(.rs b/tests/examples/test-invalid-utf8-Ã(.rs
deleted file mode 100644
index bcd68d2b..00000000
--- a/tests/examples/test-invalid-utf8-Ã(.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-fn print_square(num: f64) {
- let result = f64::powf(num, 2.0);
- println!("The square of {:.2} is {:.2}.", num, result);
-}
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs
index c318aa47..89c15832 100644
--- a/tests/integration_tests.rs
+++ b/tests/integration_tests.rs
@@ -632,12 +632,26 @@ fn filename_multiple_err() {
#[test]
fn file_with_invalid_utf8_filename() {
use std::ffi::OsStr;
+ use std::fs::File;
+ use std::io::Write;
use std::os::unix::ffi::OsStrExt;
+ use tempdir::TempDir;
+
+ let tmp_dir = TempDir::new("bat_test").expect("can create temporary directory");
+ let file_path = tmp_dir
+ .path()
+ .join(OsStr::from_bytes(b"test-invalid-utf8-\xC3(.rs"));
+ {
+ let mut file = File::create(&file_path).expect("can create temporary file");
+ writeln!(file, "dummy content").expect("can write to file");
+ }
+
bat()
- .arg(OsStr::from_bytes(b"test-invalid-utf8-\xC3(.rs"))
+ .arg(file_path.as_os_str())
.assert()
- .success();
+ .success()
+ .stdout("dummy content\n");
}
#[test]