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

Function parse_test

cranelift/reader/src/parser.rs:125–174  ·  view source on GitHub ↗

Parse the entire `text` as a test case file. The returned `TestFile` contains direct references to substrings of `text`.

(text: &'a str, options: ParseOptions<'a>)

Source from the content-addressed store, hash-verified

123///
124/// The returned `TestFile` contains direct references to substrings of `text`.
125pub fn parse_test<'a>(text: &'a str, options: ParseOptions<'a>) -> ParseResult<TestFile<'a>> {
126 let _tt = timing::parse_text();
127 let mut parser = Parser::new(text);
128
129 // Gather the preamble comments.
130 parser.start_gathering_comments();
131
132 let isa_spec: isaspec::IsaSpec;
133 let commands: Vec<TestCommand<'a>>;
134
135 // Check for specified passes and target, if present throw out test commands/targets specified
136 // in file.
137 match options.passes {
138 Some(pass_vec) => {
139 parser.parse_test_commands();
140 commands = parser.parse_cmdline_passes(pass_vec);
141 parser.parse_target_specs(&options)?;
142 isa_spec = parser.parse_cmdline_target(options.target)?;
143 }
144 None => {
145 commands = parser.parse_test_commands();
146 isa_spec = parser.parse_target_specs(&options)?;
147 }
148 };
149 let features = parser.parse_cranelift_features()?;
150
151 // Decide between using the calling convention passed in the options or using the
152 // host's calling convention--if any tests are to be run on the host we should default to the
153 // host's calling convention.
154 parser = if commands.iter().any(|tc| tc.command == "run") {
155 let host_default_calling_convention = CallConv::triple_default(&Triple::host());
156 parser.with_default_calling_convention(host_default_calling_convention)
157 } else {
158 parser.with_default_calling_convention(options.default_calling_convention)
159 };
160
161 parser.token();
162 parser.claim_gathered_comments(AnyEntity::Function);
163
164 let preamble_comments = parser.take_comments();
165 let functions = parser.parse_function_list()?;
166
167 Ok(TestFile {
168 commands,
169 isa_spec,
170 features,
171 preamble_comments,
172 functions,
173 })
174}
175
176/// Parse a CLIF comment `text` as a run command.
177///

Callers 11

runFunction · 0.85
nopFunction · 0.85
parse_functionsFunction · 0.85
test_fileFunction · 0.85
isa_specFunction · 0.85
detailsFunction · 0.85
runFunction · 0.85
run_testFunction · 0.85
handle_moduleFunction · 0.85
runMethod · 0.85
run_file_contentsFunction · 0.85

Calls 15

OkFunction · 0.85
parse_test_commandsMethod · 0.80
parse_cmdline_passesMethod · 0.80
parse_target_specsMethod · 0.80
parse_cmdline_targetMethod · 0.80
anyMethod · 0.80
tokenMethod · 0.80
take_commentsMethod · 0.80

Tested by 4

nopFunction · 0.68
test_fileFunction · 0.68
isa_specFunction · 0.68
detailsFunction · 0.68