MCPcopy Create free account
hub / github.com/glideapps/quicktype / test

Method test

test/fixtures.ts:201–243  ·  view source on GitHub ↗
(
    filename: string,
    additionalRendererOptions: RendererOptions,
    additionalFiles: string[]
  )

Source from the content-addressed store, hash-verified

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) {

Callers 1

runWithSampleFunction · 0.45

Calls 6

execFunction · 0.90
compareJsonFileToJsonFunction · 0.90
debugFunction · 0.90
quicktypeFunction · 0.90
quicktypeForLanguageFunction · 0.90
runCommandMethod · 0.80

Tested by

no test coverage detected