From 026237b91153893098a57d8ebb15db1f17dae074 Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Fri, 10 Jul 2015 00:53:11 -0400 Subject: [PATCH] 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 --- %site | 1 + Makefile | 33 --------------------------------- README.md | 7 +++++-- site | 24 +++++++++++++++++++++++- site-test | 7 ------- 5 files changed, 29 insertions(+), 43 deletions(-) create mode 120000 %site delete mode 100644 Makefile mode change 120000 => 100755 site delete mode 100755 site-test diff --git a/%site b/%site new file mode 120000 index 0000000..a7c0769 --- /dev/null +++ b/%site @@ -0,0 +1 @@ +dist/build/blog-rekahsoft-ca/blog-rekahsoft-ca \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index f614925..0000000 --- a/Makefile +++ /dev/null @@ -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 diff --git a/README.md b/README.md index cc2da4a..5630b76 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/site b/site deleted file mode 120000 index a7c0769..0000000 --- a/site +++ /dev/null @@ -1 +0,0 @@ -dist/build/blog-rekahsoft-ca/blog-rekahsoft-ca \ No newline at end of file diff --git a/site b/site new file mode 100755 index 0000000..042fb8f --- /dev/null +++ b/site @@ -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 diff --git a/site-test b/site-test deleted file mode 100755 index a25d4a4..0000000 --- a/site-test +++ /dev/null @@ -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