Simplify test scripts & document them in CONTRIBUTING.md

exif-summary
Romain 7 years ago
parent 208f0f0212
commit 870b60de17

@ -1,2 +1,2 @@
node_modules
test-integration/output-actual
test-snapshot/output-actual

@ -1,13 +1,31 @@
Please make sure the tests are passing when submitting a code change:
Please make sure the tests are passing when submitting a code change.
## Automated tests
Thumbsup is covered by several types of tests.
| Command | Tests |
|---------|-------|
| npm run lint | Static code analysis |
| npm run unit | Unit tests |
| npm test | Linting + unit tests |
| scripts/record | Creates a new snapshot |
| scripts/verify | Compares a brand new gallery against the snapshot |
| scripts/cibuild | Runs all possible tests |
Due to the nature of `thumbsup`, even some unit tests require a working runtime environment including `exiftool`, `graphicsmagick` and `ffmpeg`.
You can run the entire test suite inside Docker using:
```bash
cd ~/thumbsup
npm install
./scripts/cibuild
docker build .
```
For more confidence, you can also run `thumbsup` against the demo galleries at https://github.com/thumbsup/demos
## Manual tests
For more confidence, you can also run `thumbsup` against the demo galleries at https://github.com/thumbsup/demos.
This is also valuable when working on a theme or cosmetic changes.
```bash
# prepare local thumbsup for linking

6
.gitignore vendored

@ -1,6 +1,6 @@
node_modules
test-integration/output-actual
test-integration/output-expected/public
test-integration/output-expected/metadata.json
test-snapshot/output-actual
test-snapshot/output-expected/public
test-snapshot/output-expected/metadata.json
.DS_Store
thumbsup.db

@ -1,5 +1,5 @@
.github
.travis.yml
test
test-integration
test-snapshot
scripts

@ -23,12 +23,12 @@ Simply point `thumbsup` to a folder with photos & videos. All nested folders
```bash
npm install -g thumbsup
thumbsup --input ./media --output ./website
thumbsup --input ./photos --output ./gallery
```
![Screen recording](docs/demo.gif)
There are many more command line arguments to customise the output.
There are many command line arguments to customise the output.
See the website for the full documentation: https://thumbsup.github.io.
## Requirements
@ -39,7 +39,7 @@ Thumbsup requires the following dependencies:
- [GraphicsMagick](http://www.graphicsmagick.org/): `brew install graphicsmagick`
- [FFmpeg](http://www.ffmpeg.org/): `brew install ffmpeg`
You can also run `thumbsup` as a Docker container ([thumbsupgallery/thumbsup](https://hub.docker.com/r/thumbsupgallery/thumbsup/)) which pre-packages all the dependencies above.
You can run thumbsup as a Docker container ([thumbsupgallery/thumbsup](https://hub.docker.com/r/thumbsupgallery/thumbsup/)) which pre-packages all the dependencies above.
## Sample gallery
@ -124,8 +124,5 @@ DEBUG="*" thumbsup [options] | tee
# [16:04:57] media/thumbs/photo-1446822622709-e1c7ad6e82d52.jpg [completed]
```
Please make sure the tests are passing when submitting a code change:
```bash
./scripts/cibuild
```
If you want to contribute some code, please check out the [contributing guidelines](.github/CONTRIBUTING.md)
for an overview of the design and a run-through of the different automated/manual tests.

@ -23,8 +23,9 @@
"thumbsup": "./bin/thumbsup.js"
},
"scripts": {
"pkglint": "require-lint --ignore-extra lightgallery --ignore-extra video.js",
"test": "standard && npm run pkglint && mocha"
"lint": "standard && require-lint --ignore-extra lightgallery --ignore-extra video.js",
"unit": "mocha",
"test": "npm run lint && mocha"
},
"dependencies": {
"async": "^2.5.0",

@ -10,8 +10,9 @@ echo "--- Verify lightgallery dependency is built in"
grep \"lightgallery\" package.json 1>/dev/null
echo "--- Comparing gallery snapshot"
./test-integration/test
scripts/verify
echo ""
echo "================"
echo "Build successful"
echo "================"

@ -2,7 +2,8 @@
set -eou pipefail
# Run tests inside the integration folder
pushd "${BASH_SOURCE%/*}" >/dev/null || exit
DIR="${BASH_SOURCE%/*}"
pushd "${DIR}/../test-snapshot" >/dev/null || exit
trap finish EXIT
function finish {
popd >/dev/null

@ -2,7 +2,8 @@
set -eou pipefail
# Run tests inside the integration folder
pushd "${BASH_SOURCE%/*}" >/dev/null || exit
DIR="${BASH_SOURCE%/*}"
pushd "${DIR}/../test-snapshot" >/dev/null || exit
trap finish EXIT
function finish {
popd >/dev/null
@ -28,7 +29,4 @@ for expected in $(find output-expected/media -name "*.jpg"); do
done
unset IFS; set +f
echo "-------------------------------"
echo "Output is identical to snapshot"
echo "BUILD SUCCESSFUL"
echo "-------------------------------"

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Loading…
Cancel
Save