Returns a suitable directory to place output for tests within. This tries to pick a location in the `target` directory that can be relatively easily debugged if a test goes wrong.
(suite_name: &str, gen_name: &str, wit_name: &str)
| 13 | /// This tries to pick a location in the `target` directory that can be |
| 14 | /// relatively easily debugged if a test goes wrong. |
| 15 | pub fn test_directory(suite_name: &str, gen_name: &str, wit_name: &str) -> PathBuf { |
| 16 | let mut me = std::env::current_exe().unwrap(); |
| 17 | me.pop(); // chop off exe name |
| 18 | me.pop(); // chop off 'deps' |
| 19 | me.pop(); // chop off 'debug' / 'release' |
| 20 | me.push(format!("{suite_name}-tests")); |
| 21 | me.push(gen_name); |
| 22 | |
| 23 | // replace `-` with `_` for Python where the directory needs to be a valid |
| 24 | // Python package name. |
| 25 | me.push(wit_name.replace("-", "_")); |
| 26 | |
| 27 | drop(fs::remove_dir_all(&me)); |
| 28 | fs::create_dir_all(&me).unwrap(); |
| 29 | return me; |
| 30 | } |
| 31 | |
| 32 | /// Helper function to execute a process during tests and print informative |
| 33 | /// information if it fails. |
no test coverage detected