Skip to content

Add a script to verify json syntax #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: bash

sudo: false

addons:
apt:
packages:
- jq

script:
- bin/jsonlint
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Please see the [contributing guide](https://github.com/exercism/x-api/blob/maste

## Test Data Format

Each problem can have a file <problem>.json containing standard test data.
Each problem can have a file <problem>.json containing standard test data.
This data can be incoporated into test programs manually or extracted by a
program. The file contains a single JSON object with a key for documentation
and keys for various tests that may be meaningful for a problem.
Expand All @@ -24,7 +24,18 @@ Each test uses a key name representative of the test and an object as the
value. This object has two keys, "Description" and "Cases". Description has
a list of strings as its value. Cases has a list of objects as its value.
Each case object represents a separate test case. A case object should have
a description field and fields for inputs and outputs. A test case description should be a short phrase, suitable to be included in an error message.
a description field and fields for inputs and outputs. A test case description
should be a short phrase, suitable to be included in an error message.

## Automated Tests

The only thing that we're testing at the moment, is whether or not shared test data
is valid json.

If you want to run this before you commit, you will need to install
[jq](https://stedolan.github.io/jq/download/). Then run the script with:

bin/jsonlint

## License

Expand Down
11 changes: 11 additions & 0 deletions bin/jsonlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

STATUS=0
for f in $(ls *.json); do
cat $f | jq . > /dev/null 2>&1
if [ $? != 0 ]; then
echo "Invalid json: $f"
STATUS=1
fi
done
exit $STATUS