From b2df76b61785779d2e00f5fae845f69ac7481c18 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Wed, 27 Nov 2013 11:55:00 +0100 Subject: [PATCH 1/2] better updater --- auto-update | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/auto-update b/auto-update index ae2309d..16d5aca 100755 --- a/auto-update +++ b/auto-update @@ -1,11 +1,26 @@ #!/usr/bin/env zsh +autoload colors +colors +for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do + eval $COLOR='$fg_no_bold[${(L)COLOR}]' + eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]' +done +eval RESET='$reset_color' + +latestThread=0 relaunchCompilation() { while read line; do if (( $( print -- $line | grep '.cabal-sandbox' | wc -l) == 0 )); then - print "$line" - cabal install && \ - ./.cabal-sandbox/bin/test-holy-project + (($latestThread>0)) && \ + (( $(ps x | awk "\$1 == $latestThread" | wc -l)>0 )) && { + print -- "\n${RED}STOPPED${RESET}" + kill $latestThread + } + print "${BLUE}$line${RESET}" + { cabal install && \ + ./.cabal-sandbox/bin/test-holy-project } & + latestThread=$! fi done } @@ -22,7 +37,7 @@ Darwin) tmp=$(date +"%s") t=$tmp while true; do - tmp=$t + tmp=$(( $t - 1 )) t=$(date +"%s") for fic in {src,test}/**/*.hs(.) *.cabal; do # note to use on OS X, use "stat -f %m $checkfile" instead From 55469c6137fa5e775cdfde8e742de14fd5b24c9f Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Wed, 27 Nov 2013 15:57:49 +0100 Subject: [PATCH 2/2] add some test --- holy-project.cabal | 2 +- src/HolyProject/GitHubAPI.hs | 4 +++- src/HolyProject/Swallow.hs | 4 ---- test/HolyProject/StringUtils/Test.hs | 22 ++++++++++++++++++++++ test/HolyProject/Swallow/Test.hs | 13 ------------- test/Test.hs | 4 ++-- 6 files changed, 28 insertions(+), 21 deletions(-) delete mode 100644 src/HolyProject/Swallow.hs create mode 100644 test/HolyProject/StringUtils/Test.hs delete mode 100644 test/HolyProject/Swallow/Test.hs diff --git a/holy-project.cabal b/holy-project.cabal index cbac1a4..5603e73 100644 --- a/holy-project.cabal +++ b/holy-project.cabal @@ -56,7 +56,7 @@ executable holy-project library exposed-modules: HolyProject - , HolyProject.Swallow + , HolyProject.StringUtils , HolyProject.Coconut -- other-modules: -- other-extensions: diff --git a/src/HolyProject/GitHubAPI.hs b/src/HolyProject/GitHubAPI.hs index b203736..060d8ab 100644 --- a/src/HolyProject/GitHubAPI.hs +++ b/src/HolyProject/GitHubAPI.hs @@ -1,5 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} -module HolyProject.GitHubAPI where +module HolyProject.GitHubAPI + (searchGHUserFromEmail) +where import qualified Data.ByteString.Lazy.Char8 as LZ -- HTTP request and JSON handling diff --git a/src/HolyProject/Swallow.hs b/src/HolyProject/Swallow.hs deleted file mode 100644 index ec5b702..0000000 --- a/src/HolyProject/Swallow.hs +++ /dev/null @@ -1,4 +0,0 @@ -module HolyProject.Swallow (swallow) where - -swallow :: String -> String -> String -swallow prefix suffix = prefix ++ suffix diff --git a/test/HolyProject/StringUtils/Test.hs b/test/HolyProject/StringUtils/Test.hs new file mode 100644 index 0000000..26b2841 --- /dev/null +++ b/test/HolyProject/StringUtils/Test.hs @@ -0,0 +1,22 @@ +module HolyProject.StringUtils.Test +( stringUtilsSuite +) where +import Test.Tasty (testGroup, TestTree) +import Test.Tasty.HUnit +import HolyProject.StringUtils + +stringUtilsSuite :: TestTree +stringUtilsSuite = testGroup "StringUtils" + [ testCase "projectNameFromString space" + (testProjectNameFromString "Holy Project" "holy-project") + , testCase "projectNameFromString dash" + (testProjectNameFromString "Holy-Project" "holy-project") + , testCase "projectNameFromString caps" + (testProjectNameFromString "Holy PROJECT" "holy-project") + , testCase "projectNameFromString underscore" + (testProjectNameFromString "Holy_PROJECT" "holy_project") + ] + +testProjectNameFromString :: String -> String -> Assertion +testProjectNameFromString input expectedoutput = + expectedoutput @=? projectNameFromString input diff --git a/test/HolyProject/Swallow/Test.hs b/test/HolyProject/Swallow/Test.hs deleted file mode 100644 index 1329c2e..0000000 --- a/test/HolyProject/Swallow/Test.hs +++ /dev/null @@ -1,13 +0,0 @@ -module HolyProject.Swallow.Test - (swallowSuite) -where -import Test.Tasty (testGroup, TestTree) -import Test.Tasty.HUnit -import HolyProject.Swallow - -swallowSuite :: TestTree -swallowSuite = testGroup "Swallow" - [testCase "swallow test" testSwallow] - -testSwallow :: Assertion -testSwallow = "something" @=? swallow "some" "thing" diff --git a/test/Test.hs b/test/Test.hs index ce19fdb..ed6fd3c 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -2,7 +2,7 @@ module Main where import Test.Tasty (defaultMain,testGroup,TestTree) -import HolyProject.Swallow.Test +import HolyProject.StringUtils.Test import HolyProject.Coconut.Test main :: IO () @@ -10,6 +10,6 @@ main = defaultMain tests tests :: TestTree tests = testGroup "All Tests" - [ swallowSuite + [ stringUtilsSuite , coconutSuite ]