Wrap site tool to allow testing option

Instead of having a symbolic link from ./site to the executable in
dist/build/blog-rekahsoft-ca/blog-rekahsoft-ca, a separate test
running script ./site-test and a Makefile (which is redundant), have a
single shell script that wraps the blog-rekahsoft-ca executable and adds
a test option along with a switch to start selenium (-s|--run-selenium).

Updated README accordingly and removed unnecessary Makefile, and
site-test. Moved the symbolic link ./site to ./%site.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
This commit is contained in:
Collin J. Doering 2015-07-10 00:53:11 -04:00
parent 1bc0beefab
commit 026237b911
5 changed files with 29 additions and 43 deletions

1
%site Symbolic link
View File

@ -0,0 +1 @@
dist/build/blog-rekahsoft-ca/blog-rekahsoft-ca

View File

@ -1,33 +0,0 @@
# Makefile for blog-rekahsoft-ca
.PHONY: all configure clean build site deploy preDeploy test server
all: clean build test
configure:
cabal configure --enable-tests
clean:
rm -Rf _site _cache
cabal clean
build: configure
cabal build
site: build
./site rebuild
deploy: site preDeploy test
@echo "Deploying website..."
@rsync -rpogtzcv --delete -e ssh _site/ collin@rekahsoft.ca:~/public_html/blog/
preDeploy: _site
@echo "Removing empty files..."
@find _site -type f -empty -exec rm -v {} \;
@echo "\n"
test: site preDeploy
cabal test --show-details=always --test-option=--color
server: build site
./site server

View File

@ -60,8 +60,11 @@ To the run the tests that accompany this site, one must have [Selenium][] instal
instances running on port 4444. Then one must run the following:`
$ cabal configure --enable-tests
$ cabal install --only-dependencies
$ cabal test
$ cabal install --enable-tests --only-dependencies
$ ./site test -s
The `-s` or `--run-selenium` option to `site test` starts a selenium server before running the
tests. Another way to run the tests is using cabal directly by running `cabal test`.
## Issues <a name="issues"></a>

1
site
View File

@ -1 +0,0 @@
dist/build/blog-rekahsoft-ca/blog-rekahsoft-ca

23
site Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
if [ "$1" == "test" ]; then
if [ "$2" == "-s" ] || [ "$2" == "--run-selenium" ]; then
if ! type selenium &> /dev/null; then
echo "Failed to run Selenium. It must not be installed or not accessible on \$PATH!"
exit 1
fi
echo "Running Selenium..."
selenium 2> /dev/null &
sleep 3s
fi
# Remove empty files under directory _site
echo "Removing empty files..."
find _site -type f -empty -exec rm -v {} \;
# Test site
cabal test --show-details=always --test-option=--color
else
exec "./%site" "$@"
fi

View File

@ -1,7 +0,0 @@
#!/bin/bash
# Remove empty files under directory _site
find _site -type f -empty -exec rm -v {} \;
# Test site
cabal test --show-details=always --test-option=--color