You can make a test script use grep
and test
to check for generated output. Since grep will die with an error code if it doesn't match anything, the test will be considered a failure.
#!/usr/bin/env sh
set -o errexit # die on errors
grep "<title>" _site/index.html >/dev/null
grep display _site/style.css >/dev/null
grep function _site/script.js >/dev/null
test -f _site/image.jpg # check for file existence
You can even integrate these with your Travis-CI tests. (Learn more about build configuration from their documentation.)
before_script: bundle exec jekyll build
script: ./test/test.sh
Another good way is to use a Makefile
so you can simply use make test
to invoke tests.
test: _site
grep display _site/style.css >/dev/null
grep function _site/script.js >/dev/null
test -f _site/image.jpg #check for file existence
_site:
bundle
bundle exec jekyll build --safe