Commit 6974bfe8 authored by Stephan Uhlmann's avatar Stephan Uhlmann

code quality additions

- added tests
- fixed issues found by shellcheck
- check for image files before generating directoy structure, so if none are
  found, nothing will be written
- do not print version number and dates in html files so that an execution on
  the same data always produces the same output which makes it easier to test
- removed version from script and --version option
parent 3f87c3a9
Pipeline #25416077 failed with stage
in 1 minute and 29 seconds
stages:
- test
codequality:
stage: test
image: alpine:latest
before_script:
- wget -nv https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz
- tar xvJf shellcheck-stable.linux.x86_64.tar.xz
- cp shellcheck-stable/shellcheck /usr/local/bin
script:
- shellcheck easygg
- shellcheck test/test.sh
tests:
stage: test
image: centos:latest
before_script:
- yum install -y bash ImageMagick
- yum install -y epel-release
- yum install -y jhead
script:
- cd test && ./test.sh
# ChangeLog
## [Unreleased]
### Added
## Changed
- check for image files before generating directoy structure, so if none are
found, nothing will be written
- do not print version number and dates in html files so that an execution on
the same data always produces the same output which makes it easier to test
- fixed issues found by shellcheck
- removed version from script and --version option
## [0.5] 2012-09-04
### Added
- added LICENSE.txt
......@@ -9,6 +21,7 @@
- renamed options -sd/--slide-dimension -fd/--full-dimension
- use http://keepachangelog.com formatting for this CHANGELOG
## [0.4] 2010-12-11
### Added
- width and height of scaled images is used in html image tag
......
......@@ -9,7 +9,7 @@ Features:
The program is a Bash shell script. It uses the tools `convert` from [ImageMagick](http://www.imagemagick.org/) and [`jhead`](http://www.sentex.net/~mwandel/jhead/). If you don't have them, install them first.
Because the program is so easy (hence the name) it needs no parameters. Just call it in a directory with JPG or PNG images and it will create a subdirectory with a ready to use gallery. You can override several default options though. Call the script with parameter -h for help.
Because the program is so easy (hence the name) it needs no parameters. Just call it in a directory with JPG or PNG images and it will create a subdirectory with a ready to use gallery. You can override several default options though. Call the script with parameter *--help* for help.
To see how an easyGG generated gallery looks like, see the [demo](https://su2.info/easygg/demo/). That are pictures from a trip to the
nice city Strasbourg :)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/bin/bash
TESTS_ALL=0
TESTS_FAIL=0
# $1 = test name
# $2 = command
# $3 = expected status code
runtest()
{
TESTS_ALL=$((TESTS_ALL + 1))
echo "####################"
echo "Running test ${TESTS_ALL}: $1"
OUTPUT="$( eval "$2" )"
export RET=$?
export OUTPUT
if eval "$3";
then
echo "OK"
else
echo -e "${OUTPUT}"
echo "FAILED"
TESTS_FAIL=$((TESTS_FAIL + 1))
fi
}
# tests if it stops when no images are found
runtest "noimages" "../easygg 2>&1" "[ \$RET -eq 1 ] && ( echo \"\$OUTPUT\" | grep \"No image files found.\" >/dev/null )"
cd dataset1 || exit 1
# tests if a normal run is successful
runtest "dataset1 execution" "../../easygg 2>&1" "[ \$RET -eq 0 ] && ( echo \"\$OUTPUT\" | grep \"Finished.\" >/dev/null )"
# tests if expected number of files are produced
runtest "dataset1 files" "echo easygg/* | md5sum | grep \"14690a60ed80f7d53176e3c703fe1b68\"" "[ \$RET -eq 0 ]"
# tests if all *.html files produce no parsing errors
runtest "dataset1 html validation" "xmllint --noout --valid --html easygg/*.html 2>&1" "[ \$RET -eq 0 ] && [ -z \"\$OUTPUT\" ]"
# tests if same content is produced
runtest "dataset1 content" "cat easygg/* | md5sum | grep \"ceedae79705a0c7efcc79e37ca3a6b7b\"" "[ \$RET -eq 0 ]"
rm -rf easygg
echo "####################"
if [ ${TESTS_FAIL} -eq 0 ];
then
echo "All ${TESTS_ALL} tests successful."
exit 0
else
echo "${TESTS_FAIL} of ${TESTS_ALL} tests failed."
exit 1
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment