From 42a10e3b9b0a0a5f20ffdc70bb502c48db272a40 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Sun, 7 Jul 2019 09:00:31 -0700 Subject: [PATCH] Automatically test parsing of all the .otto examples in the examples/ directory --- examples/{rubygem.otto => rubygem.otto.draft} | 0 grammar/__tests__/pipeline.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+) rename examples/{rubygem.otto => rubygem.otto.draft} (100%) diff --git a/examples/rubygem.otto b/examples/rubygem.otto.draft similarity index 100% rename from examples/rubygem.otto rename to examples/rubygem.otto.draft diff --git a/grammar/__tests__/pipeline.ts b/grammar/__tests__/pipeline.ts index 7a09933..91f000f 100644 --- a/grammar/__tests__/pipeline.ts +++ b/grammar/__tests__/pipeline.ts @@ -2,10 +2,23 @@ * This test file will verify the parsing behavior of the pipeline block */ +import fs from 'fs'; +import path from 'path'; + import { MIN_PIPELINE, parse } from '../utils'; describe('pipeline {}', () => { it('should pass with the minimum viable pipeline', () => { expect(parse(MIN_PIPELINE)).toHaveLength(0); }); + + describe('with full examples', () => { + const examples_dir = path.join(__dirname, '..', '..', 'examples'); + fs.readdirSync(examples_dir).filter(filename => filename.endsWith('.otto')).map((filename) => { + it(`should be able to parse ${filename}`, () => { + const buffer = fs.readFileSync(path.join(examples_dir, filename), 'utf8'); + expect(parse(buffer)).toHaveLength(0); + }); + }); + }); });