From e41d768b17f0eefce1d50a9bc2834e49db6176bd Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 31 Aug 2019 20:52:51 +0300 Subject: Refactor: share identical input files between scenarios --- fable-arch.md | 144 +++++++++++++------------------------------------------- fable-arch.yaml | 2 +- 2 files changed, 33 insertions(+), 113 deletions(-) diff --git a/fable-arch.md b/fable-arch.md index 686524a..c574466 100644 --- a/fable-arch.md +++ b/fable-arch.md @@ -426,6 +426,33 @@ other resource constraints. # Acceptance tests for Fable {#acceptance} +## Shared files between scenarios + +The scenarios will use the files under different names. + +### b.yaml—Bindings file + +```{#simple.yaml .yaml} +- given: precondition foo + function: precond +- when: I do bar + function: do +- then: bar was done + function: was_done +``` + +### f.py—Python file with functions + +```{#simple.py .python} +state = {'done': False} +def precond(ctx): + pass +def do(ctx): + state['done'] = True +def was_done(ctx): + assert state['done'] +``` + ## The simplest possible scenario This tests that Fable can build a PDF and an HTML document, and @@ -434,7 +461,7 @@ generating the test program from an input file, running the test program, and examining the log file. ```fable -given files simple.md, simple.yaml, and simple.py +given files simple.md, simple.yaml (from b.yaml), and simple.py (from f.py) when I run ftt-docgen --pdf simple.md then file simple.pdf exists @@ -463,35 +490,14 @@ then bar was done ``` ~~~~ -### simple.yaml—bindings file - -```{#simple.yaml .yaml} -- given: precondition foo - function: precond -- when: I do bar - function: do -- then: bar was done - function: was_done -``` - -### simple.py—Python file with functions -```{#simple.py .python} -state = {'done': False} -def precond(ctx): - pass -def do(ctx): - state['done'] = True -def was_done(ctx): - assert state['done'] -``` ## A scenario step fails This tests that Fable can run handle a scenario step failing. ```fable -given files fail.md, fail.yaml, and fail.py +given files fail.md, fail.yaml (from b.yaml), and fail.py (from f.py) when I run ftt-codegen --run fail.md then log file says scenario "Fail" was run @@ -512,26 +518,6 @@ then bar was done ``` ~~~~ -### fail.md—bindings file - -```{#fail.yaml .yaml} -- given: precondition foo - function: precond -- then: bar was done - function: was_done -``` - -### fail.md—Python file with functions - -```{#fail.py .python} -state = {'done': False} -def precond(ctx): - pass -def do(ctx): - state['done'] = True -def was_done(ctx): - assert state['done'] -``` ## Two scenarios in the same markdown file @@ -542,7 +528,7 @@ FIXME: This and all other tests that run more than one scenario should handle scenarios being run in random order, and concurrently. ```fable -given files two.md, two.yaml, and two.py +given files two.md, two.yaml (from b.yaml), and two.py (from f.py) when I run ftt-codegen --run two.md then log file says scenario "First" was run @@ -580,28 +566,6 @@ then bar was done ``` ~~~~ -### two.yaml—bindings file - -```{#two.yaml .yaml} -- given: precondition foo - function: precond -- when: I do bar - function: do -- then: bar was done - function: was_done -``` - -### two.md—Python file with functions - -```{#two.py .python} -state = {'done': False} -def precond(ctx): - pass -def do(ctx): - state['done'] = True -def was_done(ctx): - assert state['done'] -``` ## Two scenarios, one has a failing step @@ -610,7 +574,7 @@ This tests that Fable runs both scenarios, even if one has a failing step. ```fable -given files onefails.md, onefails.yaml, and onefails.py +given files onefails.md, onefails.yaml (from b.yaml), and onefails.py (from f.py) when I run ftt-codegen --run onefails.md then log file says scenario "First" was run @@ -646,28 +610,7 @@ then bar was done ``` ~~~~ -### onefails.yaml—bindings file - -```{#two.yaml .yaml} -- given: precondition foo - function: precond -- when: I do bar - function: do -- then: bar was done - function: was_done -``` - -### onefails.md—Python file with functions -```{#two.py .python} -state = {'done': False} -def precond(ctx): - pass -def do(ctx): - state['done'] = True -def was_done(ctx): - assert state['done'] -``` ## Two scenarios, both have a failing step @@ -675,7 +618,7 @@ This tests that Fable runs both scenarios, even when both have a failing step. ```fable -given files twofail.md, twofail.yaml, and twofail.py +given files twofail.md, twofail.yaml (from b.yaml), and twofail.py (from f.py) when I run ftt-codegen --run twofail.md then log file says scenario "First" was run @@ -708,26 +651,3 @@ given precondition foo then bar was done ``` ~~~~ - -### twofail.yaml—bindings file - -```{#twofail.yaml .yaml} -- given: precondition foo - function: precond -- when: I do bar - function: do -- then: bar was done - function: was_done -``` - -### twofail.md—Python file with functions - -```{#twofail.py .python} -state = {'done': False} -def precond(ctx): - pass -def do(ctx): - state['done'] = True -def was_done(ctx): - assert state['done'] -``` diff --git a/fable-arch.yaml b/fable-arch.yaml index 0777104..770dec8 100644 --- a/fable-arch.yaml +++ b/fable-arch.yaml @@ -1,4 +1,4 @@ -- given: files (?P\S+), (?P\S+), and (?P\S+) +- given: files (?P\S+), (?P\S+) \(from (?P\S+)\), and (?P\S+) \(from (?P\S+)\) - when: I run ftt-docgen --html (?P\S+) - when: I run ftt-docgen --pdf (?P\S+) - when: I run ftt-codegen --run (?P\S+) -- cgit v1.2.1