Signed-off-by: Christina Sørensen <christina@cafkafk.com>
4 KiB
Help
Running the tests
Each exercise contains a test file.
Run the tests using the bats
program.
bats test-hello-world.bats
bats
will need to be installed.
See the Testing on the Bash track page for instructions to install bats
for your system.
bats is implemented in bash
The bats file is a bash script, with some special functions recognized by the bats
command.
You'll see some tests that look like
jq -f some-exercise.jq <<< "{some,json,here}"
That <<<
syntax is a bash Here String.
It sends the string on the right-hand side into the standard input of the program on the left-hand side.
It is (approximately) the same as
echo "{some,json,here}" | jq -f some-exercise.jq
Help for assert functions
The tests use functions from the bats-assert library.
Help for the various assert*
functions can be found there.
Skipped tests
Solving an exercise means making all its tests pass. By default, only one test (the first one) is executed when you run the tests. This is intentional, as it allows you to focus on just making that one test pass. Once it passes, you can enable the next test by commenting out or removing the
[[ $BATS_RUN_SKIPPED == true ]] || skip
annotations prepending other tests.
Overriding skips
To run all tests, including the ones with skip
annotations, you can run:
BATS_RUN_SKIPPED=true bats test-some-exercise.bats
It can be convenient to use a wrapper function to save on typing: in bash
you can do:
bats() {
BATS_RUN_SKIPPED=true command bats *.bats
}
Then run tests with just:
bats
Debugging in jq
jq
comes with a handy debug
filter.
Use it while you are developing your exercise solutions to inspect the data that is currently in the jq pipline.
See the debugging doc for more details.
Submitting your solution
You can submit your solution using the exercism submit prime-factors.jq
command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
Need to get help?
If you'd like help solving the exercise, check the following pages:
- The jq track's documentation
- The jq track's programming category on the forum
- Exercism's programming category on the forum
- The Frequently Asked Questions
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
Need more help?
- Go to the Exercism Community forum to get support and ask questions (or just chat!)
- Use the Exercism Support category if you face any issues with working in the web editor, or downloading or submitting your exercises locally.
- Use the Programming:jq category for jq-specific topics.
- Join the community on Exercism's Discord server.
- StackOverflow can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.
- Github issue tracker is where we track our development and maintainance of
jq
exercises in exercism. If none of the above links help you, feel free to post an issue here.