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>)
| 123 | /// |
| 124 | /// The returned `TestFile` contains direct references to substrings of `text`. |
| 125 | pub 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 | /// |