MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / test_directory

Function test_directory

crates/test-helpers/src/lib.rs:15–30  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

13/// This tries to pick a location in the `target` directory that can be
14/// relatively easily debugged if a test goes wrong.
15pub 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.

Callers 2

run_world_codegen_testFunction · 0.85

Calls 2

dropFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected