From e0bc2a78a84fb5864ea95905546cf815f48cb10f Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sun, 11 Sep 2011 14:59:32 -0400 Subject: [PATCH 1/4] Fix up scaffold.sh Use bash -e instead of single pipeline Unregister foobar after testing it --- yesod/test/scaffold.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/yesod/test/scaffold.sh b/yesod/test/scaffold.sh index 34798202..303a9656 100755 --- a/yesod/test/scaffold.sh +++ b/yesod/test/scaffold.sh @@ -1,3 +1,12 @@ -#!/bin/bash -x +#!/bin/bash -ex -rm -rf foobar && runghc main.hs init && cd foobar && cabal install && cabal install -fdevel && cd .. +rm -rf foobar +runghc main.hs init + +( + cd foobar + cabal install + cabal install -fdevel +) + +ghc-pkg unregister foobar From 2fdb24b2c14f5b280532b9ac4f73f6fe3762c9d1 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sun, 11 Sep 2011 15:00:20 -0400 Subject: [PATCH 2/4] Complete rewrite of test/run.sh Output is more useful (IMO). Everything is silenced for the duration of the tests but a count of tests/failures and any errors are output at the end. Pass --verbose to watch stdout during the tests. Logic is also seperated into core setup/runners and individual test definitions. Should be more easily extensible. --- yesod/test/run.sh | 111 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 91 insertions(+), 20 deletions(-) diff --git a/yesod/test/run.sh b/yesod/test/run.sh index 948e7689..3b81e612 100755 --- a/yesod/test/run.sh +++ b/yesod/test/run.sh @@ -1,26 +1,97 @@ -#!/bin/bash -ex +#!/bin/bash -e # -# A wrapper for the shelltest test. Passes along options to shelltest. +# Runs test/scaffold.sh with a variety of inputs. Hides all output +# besides failure details. # -# cabal install shelltestrunner +### -cabal clean && cabal install && cabal sdist +[[ "$1" =~ -v|--verbose ]] && stdout=/dev/stdout || stdout=/dev/null -# I am not that good at shell scripting -# this for loop only operates on 1 file (as per tail -1) -for f in $(ls -1rt dist/*.tar.gz | tail -1) -do - tar -xzvf $f && cd `basename $f .tar.gz` +tmp='/tmp' +pwd="$PWD" - # shelltest is designed to show you the diff of an expected stdout/stdin. We don't care about that. If it compiles, it compiles - # shelltest ../test/scaffold.shelltest --color --diff --all $@ -- --hide-successes +pkg= +dir= - ../test/scaffold.sh < ../test/sqlite-input.txt && - ../test/scaffold.sh < ../test/postgresql-input.txt && - ../test/scaffold.sh < ../test/tiny-input.txt && - ../test/scaffold.sh < ../test/mongodb-input.txt || - (echo "FAILED" && exit 1) - cd .. - rm -r `basename $f .tar.gz` -done -echo "PASSED" +failures=() +n_tested=0 +n_failed=0 + +# runs the function named by $1, silencing stdout and redirecting stderr +# to /tmp/function.errors. failures are tracked to be reported on during +# cleanup +run_test() { # {{{ + local test_function="$*" + + n_tested=$((n_tested+1)) + + if $test_function >"$stdout" 2>"$tmp/$test_function.errors"; then + echo -n '.' + [[ -f "$tmp/$test_function.errors" ]] && rm "$tmp/$test_function.errors" + else + echo -n 'F' + failures+=( "$test_function" ) + n_failed=$((n_failed+1)) + fi +} +# }}} + +# changes back to the original directory, removes the dist file and +# outputs a report of tests and failures +cleanup() { # {{{ + cd "$pwd" + [[ -d "$dir" ]] && rm -r "$dir" + + echo + echo + echo "Tests: $n_tested, Failures: $n_failed." + echo + + [[ $n_failed -eq 0 ]] && return 0 + + for test in ${failures[@]}; do + echo "Failure: $test" + echo 'details:' + echo + + if [[ -f "$tmp/$test.errors" ]]; then + cat "$tmp/$test.errors" + rm "$tmp/$test.errors" + else + echo '' + fi + + echo + done + + return $n_failed +} +# }}} + +# compilation is test #1, sets global variable dir. other tests are run +# from within this directory and it is removed as part of cleanup +test_compile() { + cabal clean + cabal install + cabal sdist + + read -r pkg < <(find dist/ -type f -name '*.tar.gz' | sort -rV) + dir="$(basename "$pkg" .tar.gz)" + + tar -xzf "$pkg" && cd "$dir" +} + +test_sqlite() { ../test/scaffold.sh < ../test/sqlite-input.txt ; } +test_postgresql() { ../test/scaffold.sh < ../test/postgresql-input.txt; } +test_mongodb() { ../test/scaffold.sh < ../test/mongodb-input.txt ; } +test_tiny() { ../test/scaffold.sh < ../test/tiny-input.txt ; } + +echo 'Started' +run_test 'test_compile' +run_test 'test_sqlite' +run_test 'test_postgresql' +run_test 'test_mongodb' +run_test 'test_tiny' +cleanup + +exit $? From e21d29b0df64a397cfe7c7f4a3cbda58f1a4f2f0 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sun, 11 Sep 2011 20:22:35 -0400 Subject: [PATCH 3/4] Add scripts submodule --- .gitmodules | 3 +++ install-all.sh | 47 ----------------------------------------------- scripts | 1 + 3 files changed, 4 insertions(+), 47 deletions(-) create mode 100644 .gitmodules delete mode 100755 install-all.sh create mode 160000 scripts diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..91468aac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "scripts"] + path = scripts + url = git://github.com/yesodweb/scripts.git diff --git a/install-all.sh b/install-all.sh deleted file mode 100755 index 9b135d20..00000000 --- a/install-all.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -e - -# allow a CABAL env var to override -CABAL=${CABAL:-cabal} - -# install testing dependencies -$CABAL install HUnit QuickCheck 'hspec >= 0.6.1 && < 0.7' shelltestrunner - -pkgs=( yesod-core - yesod-json - yesod-static - yesod-persistent - yesod-newsfeed - yesod-form - yesod-auth - yesod-sitemap - yesod - ) - -# install each sub-respository -for pkg in "${pkgs[@]}"; do - echo "Installing $pkg..." - - ( - cd "./$pkg" - - if [ "$1" = "--clean" ]; then - $CABAL clean - fi - - if ! $CABAL configure --ghc-options="-Wall -Werror"; then - $CABAL install --only-dependencies - $CABAL configure --ghc-options="-Wall -Werror" - fi - $CABAL build - - $CABAL configure --enable-tests - $CABAL build - $CABAL test - - $CABAL check - if [ "$1" != "--fast" ]; then - $CABAL haddock --executables - fi - ./Setup.lhs install - ) -done diff --git a/scripts b/scripts new file mode 160000 index 00000000..00e2390f --- /dev/null +++ b/scripts @@ -0,0 +1 @@ +Subproject commit 00e2390f2eb601d869e97fc2838cc17f63f0e343 From 03e15e2afce6f5c94333438cee43dbe0171a041e Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sun, 11 Sep 2011 20:25:27 -0400 Subject: [PATCH 4/4] update readme --- README.md | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f3735fa3..ec612e31 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -A next generation web framework using the Haskell programming language, featuring: - +A next generation web framework using the Haskell programming language, +featuring: + * safety & security guaranteed at compile time * performance * fast, compiled code * a greater concurrent load than any other web application server - * developer productivity: tools for all your basic web development needs + * developer productivity: tools for all your basic web development + needs ## Learn more: http://yesodweb.com/ - ## Installation: http://www.yesodweb.com/page/five-minutes - ## Create a new project after installing yesod init @@ -19,13 +19,18 @@ A next generation web framework using the Haskell programming language, featurin ## Installing the latest development version from github -Yesod is built upon many smaller packages, all of which can be installed with: +Yesod is built upon many smaller packages, all of which can be installed +with: - cabal update +~~~ { .bash } +cabal update - REPOS="hamlet persistent wai yesod" - for repo in $REPOS - do - git clone http://github.com/yesodweb/$repo - (cd $repo && ./install-all.sh) - done +for repo in hamlet persistent wai yesod; do + git clone http://github.com/yesodweb/$repo + ( + cd $repo + git submodule update --init + ./script/install + ) +done +~~~