Skip to content

Commit 4e41905

Browse files
wetnebdginev
authored andcommitted
tests: avoid writing to the source directory of the crate
This makes for a better separation between source code and test execution data. It is needed to make tests pass in a Debian build environment where the source directory is not writeable.
1 parent bafe4e2 commit 4e41905

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ Cargo.lock
1818
/target/
1919

2020
# Test results
21-
/tests/results/*.xml
2221
/tags

tests/base_tests.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Base API tests, to be split into distinct sub-suites later on
22
//!
3+
use std::env;
34
use std::fs::File;
45
use std::io::Read;
56

@@ -44,7 +45,8 @@ fn hello_builder() {
4445

4546
let doc_string = doc.to_string();
4647
assert!(doc_string.len() > 1);
47-
assert!(doc.save_file("tests/results/helloworld.xml").is_ok());
48+
let output_path = env::temp_dir().join("rust_libxml_tests_helloworld.xml");
49+
assert!(doc.save_file(&output_path.display().to_string()).is_ok());
4850
}
4951

5052
#[test]
@@ -69,7 +71,8 @@ fn duplicate_file() {
6971
assert!(doc_result.is_ok());
7072

7173
let doc = doc_result.unwrap();
72-
doc.save_file("tests/results/copy.xml").unwrap();
74+
let output_path = env::temp_dir().join("rust_libxml_tests_copy.xml");
75+
doc.save_file(&output_path.display().to_string()).unwrap();
7376
}
7477
}
7578

0 commit comments

Comments
 (0)