3.6 KiB
Help
Running the tests
Each exercise contains a test file. Run the tests using the
bats program.
bats hello_world.batsbats will need to be installed. See the Testing on the Bash
track page for instructions to install bats for your
system.
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 next annotation:
[[ $BATS_RUN_SKIPPED == true ]] || skipOverriding skips
To run all tests, including the ones with skip
annotations, you can run:
BATS_RUN_SKIPPED=true bats exercise_name.batsIt can be convenient to use a wrapper function to save on typing:
bats() {
BATS_RUN_SKIPPED=true command bats *.bats
}Then run tests with just:
batsSubmitting your solution
You can submit your solution using the
exercism submit error_handling.sh 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 Bash track’s documentation
- 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.
Check your code for syntax errors: paste your code into https://shellcheck.net (or install it on your machine).
Stack Overflow will be your first stop for bash questions.
- start with the
bashtag to search for your specific question: it’s probably already been asked - under the bash tag on Stackoverflow, the Learn more… link has
tons of good information.
- the “Books and Resources” section is particularly useful.
- the
bashtag on Unix & Linux is also active
External utilities
bash is a language to write “scripts” – programs that
can call external tools, such as sed, awk, date
and even programs written in other programming languages, like Python. This track does
not restrict the usage of these utilities, and as long as your solution
is portable between systems and does not require installation of third
party applications, feel free to use them to solve the exercise.
For an extra challenge, if you would like to have a better understanding of the language, try to re-implement the solution in pure bash, without using any external tools. There are some types of problems that bash cannot solve, such as floating point arithmetic and manipulating dates: for those, you must call out to an external tool.