Skip to content

Commit

Permalink
README: update docs regarding test case generators
Browse files Browse the repository at this point in the history
  • Loading branch information
robphoenix committed Apr 3, 2017
1 parent 22cd6f8 commit 87f1fe2
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ number of files there.

```sh
~/exercism/go/leap
$ tree
$ tree -a
.
├── cases_test.go
├── example_gen.go
├── example.go
├── leap.go
└── leap_test.go
├── leap_test.go
└── .meta
└── gen.go

0 directories, 5 files
1 directory, 5 files
```

This list of files can vary across exercises so let's quickly run through
Expand All @@ -61,16 +62,20 @@ each file and briefly describe what it is.
**cases_test.go** - This file contains [generated test cases](#generating-test-cases),
and will only be present in some exercises.

**example_gen.go** - This file generates the *cases_test.go* file, and will only
be present in some exercises. See [generating test cases](#generating-test-cases)
for more information.

**example.go** - This is a reference solution for the exercise.

**leap.go** - This is a *stub file*, and will only be present in some exercises.

**leap_test.go** - This is the main test file for the exercise.

**.meta/** - The *.meta* directory can be used to contain files
that are not meant to be included when a user fetches an exercise, for instance
test case generators.

**gen.go** - This file generates the *cases_test.go* file, and will only
be present in some exercises. See [generating test cases](#generating-test-cases)
for more information.

In some exercises there can be extra files, for instance the `series` exercise
contains extra test files.

Expand Down Expand Up @@ -136,7 +141,7 @@ without a stub is [twelve-days](exercises/twelve-days/). At this point users wil
have some experience in creating solutions for the exercises and can begin to
create their own solutions from scratch. Some of the later exercises may have stub
files if the author thinks there may be implementation confusion, a particularly
difficult concept, or boilerplate code needed.
difficult concept, or boilerplate code needed.

### Problem Versioning

Expand All @@ -163,17 +168,21 @@ tracks don't.

Some problems that are implemented in multiple tracks use the same inputs and
outputs to define the test suites. Where the [x-common](https://github.com/exercism/x-common)
repository contains json files with these inputs and outputs, we can generate
the test cases programmatically.
repository contains a *canonical-data.json* file with these inputs and outputs,
we can generate the test cases programmatically.

See the *example_gen.go* file in the `leap` exercise for an example of how this
See the *gen.go* file in the `leap` exercise for an example of how this
can be done.

Test case generators are named *gen.go* and are kept in a special *.meta*
directory within each exercise that makes use of a test cases generator. This
*.meta* directory will be ignored when a user fetches an exercise.

Whenever the shared JSON data changes, the test cases will need to be regenerated.
To do this, make sure that the **x-common** repository has been cloned in the same
parent-directory as the **xgo** repository. Then navigate into the **xgo**
directory and run `go run exercises/<problem>/example_gen.go`. You should see
that the `<problem>/test_cases.go` file has changed. Commit the change.
directory and run `go run exercises/<exercise>/.meta/gen.go`. You should see
that the `<exercise>/test_cases.go` file has changed. Commit the change.

## Pull requests

Expand Down

0 comments on commit 87f1fe2

Please sign in to comment.