MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / run

Function run

cranelift/src/run.rs:25–73  ·  view source on GitHub ↗
(options: &Options)

Source from the content-addressed store, hash-verified

23}
24
25pub fn run(options: &Options) -> Result<()> {
26 let stdin_exist = options
27 .files
28 .iter()
29 .find(|file| *file == Path::new("-"))
30 .is_some();
31 let filtered_files = options
32 .files
33 .iter()
34 .cloned()
35 .filter(|file| *file != Path::new("-"))
36 .collect::<Vec<_>>();
37 let mut total = 0;
38 let mut errors = 0;
39 let mut special_files: Vec<PathBuf> = vec![];
40 if stdin_exist {
41 special_files.push("-".into());
42 }
43 for file in iterate_files(&filtered_files).chain(special_files) {
44 total += 1;
45 match run_single_file(&file) {
46 Ok(_) => {
47 if options.verbose {
48 println!("{}", file.to_string_lossy());
49 }
50 }
51 Err(e) => {
52 if options.verbose {
53 println!("{}: {}", file.to_string_lossy(), e);
54 }
55 errors += 1;
56 }
57 }
58 }
59
60 if options.verbose {
61 match total {
62 0 => println!("0 files"),
63 1 => println!("1 file"),
64 n => println!("{n} files"),
65 }
66 }
67
68 match errors {
69 0 => Ok(()),
70 1 => anyhow::bail!("1 failure"),
71 n => anyhow::bail!("{n} failures"),
72 }
73}
74
75/// Run all functions in a file that are succeeded by "run:" comments
76fn run_single_file(path: &PathBuf) -> Result<()> {

Callers

nothing calls this directly

Calls 9

iterate_filesFunction · 0.85
run_single_fileFunction · 0.85
OkFunction · 0.85
chainMethod · 0.80
newFunction · 0.50
is_someMethod · 0.45
findMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected