(
filename: string,
additionalRendererOptions: RendererOptions,
additionalFiles: string[]
)
| 199 | } |
| 200 | |
| 201 | async test( |
| 202 | filename: string, |
| 203 | additionalRendererOptions: RendererOptions, |
| 204 | additionalFiles: string[] |
| 205 | ): Promise<void> { |
| 206 | if (this.language.compileCommand) { |
| 207 | exec(this.language.compileCommand); |
| 208 | } |
| 209 | compareJsonFileToJson({ |
| 210 | expectedFile: filename, |
| 211 | given: { command: this.language.runCommand(filename) }, |
| 212 | strict: false, |
| 213 | allowMissingNull: this.language.allowMissingNull |
| 214 | }); |
| 215 | |
| 216 | if (this.language.diffViaSchema) { |
| 217 | debug("* Diffing with code generated via JSON Schema"); |
| 218 | // Make a schema |
| 219 | await quicktype({ |
| 220 | src: [filename], |
| 221 | lang: "schema", |
| 222 | out: "schema.json", |
| 223 | topLevel: this.language.topLevel, |
| 224 | rendererOptions: {} |
| 225 | }); |
| 226 | // Quicktype from the schema and compare to expected code |
| 227 | shell.mv(this.language.output, `${this.language.output}.expected`); |
| 228 | await quicktypeForLanguage( |
| 229 | this.language, |
| 230 | "schema.json", |
| 231 | "schema", |
| 232 | true, |
| 233 | additionalRendererOptions |
| 234 | ); |
| 235 | |
| 236 | // Compare fixture.output to fixture.output.expected |
| 237 | exec( |
| 238 | `diff -Naur ${this.language.output}.expected ${ |
| 239 | this.language.output |
| 240 | } > /dev/null 2>&1` |
| 241 | ); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | shouldSkipTest(sample: Sample): boolean { |
| 246 | if (fs.statSync(sample.path).size > 32 * 1024 * 1024) { |
no test coverage detected