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

Method scan_dirs

cranelift/filetests/src/runner.rs:125–178  ·  view source on GitHub ↗

Scan any directories pushed so far. Push any potential test cases found.

(&mut self, pass_status: IsPass)

Source from the content-addressed store, hash-verified

123 /// Scan any directories pushed so far.
124 /// Push any potential test cases found.
125 pub fn scan_dirs(&mut self, pass_status: IsPass) {
126 // This recursive search tries to minimize statting in a directory hierarchy containing
127 // mostly test cases.
128 //
129 // - Directory entries with a "clif" or "wat" extension are presumed to be test case files.
130 // - Directory entries with no extension are presumed to be subdirectories.
131 // - Anything else is ignored.
132 //
133 while let Some(dir) = self.dir_stack.pop() {
134 match dir.read_dir() {
135 Err(err) => {
136 // Fail silently if `dir` was actually a regular file.
137 // This lets us skip spurious extensionless files without statting everything
138 // needlessly.
139 if !dir.is_file() {
140 self.path_error(&dir, &err);
141 }
142 }
143 Ok(entries) => {
144 // Read all directory entries. Avoid statting.
145 for entry_result in entries {
146 match entry_result {
147 Err(err) => {
148 // Not sure why this would happen. `read_dir` succeeds, but there's
149 // a problem with an entry. I/O error during a getdirentries
150 // syscall seems to be the reason. The implementation in
151 // libstd/sys/unix/fs.rs seems to suggest that breaking now would
152 // be a good idea, or the iterator could keep returning the same
153 // error forever.
154 self.path_error(&dir, &err);
155 break;
156 }
157 Ok(entry) => {
158 let path = entry.path();
159 // Recognize directories and tests by extension.
160 // Yes, this means we ignore directories with '.' in their name.
161 match path.extension().and_then(OsStr::to_str) {
162 Some("clif" | "wat") => self.push_test(path),
163 Some(_) => {}
164 None => self.push_dir(path),
165 }
166 }
167 }
168 }
169 }
170 }
171 if pass_status == IsPass::Pass {
172 continue;
173 } else {
174 // Get the new jobs running before moving on to the next directory.
175 self.schedule_jobs();
176 }
177 }
178 }
179
180 /// Report an error related to a path.
181 fn path_error<E: Error>(&mut self, path: &PathBuf, err: &E) {

Callers 2

runMethod · 0.80
run_passesMethod · 0.80

Calls 6

path_errorMethod · 0.80
push_testMethod · 0.80
schedule_jobsMethod · 0.80
popMethod · 0.45
pathMethod · 0.45
push_dirMethod · 0.45

Tested by

no test coverage detected