aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-11-10 15:25:23 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-11-10 15:25:23 +0100
commitaa727b8868b428a6b75e0d48a854be65242b257c (patch)
tree37be2eeff0f50effca07977eec99b7b5364bdddb
parentba7820b18c0ee8631505f7a2a764f7222a732d44 (diff)
downloadapp.sh-aa727b8868b428a6b75e0d48a854be65242b257c.tar.gz
app.sh-aa727b8868b428a6b75e0d48a854be65242b257c.tar.bz2
app.sh-aa727b8868b428a6b75e0d48a854be65242b257c.tar.xz
app.sh-aa727b8868b428a6b75e0d48a854be65242b257c.zip
o Automatically fetching Bats if not installed.HEADmaster
-rw-r--r--Makefile7
-rw-r--r--STYLE-GUIDE.txt13
-rwxr-xr-xtest/app-upgrade.bats15
3 files changed, 25 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index edf76c8..710c092 100644
--- a/Makefile
+++ b/Makefile
@@ -7,16 +7,19 @@ TESTS=$(addprefix test-,$(BATS))
test-%:
@echo === $@
- @bats $(patsubst test-%,test/%,$@)
+ @PATH=test/bats/bin:$(PATH) bats $(patsubst test-%,test/%,$@)
show-tests:
@echo BATS=$(BATS)
@echo TESTS=$(TESTS)
@echo $(addprefix set_header-,$(BINS))
-test: $(TESTS)
+test: test/bats $(TESTS)
.PHONY: test
+test/bats:
+ cd test && git clone git://github.com/sstephenson/bats.git
+
clean:
@make -s -C docs clean
.PHONY: clean
diff --git a/STYLE-GUIDE.txt b/STYLE-GUIDE.txt
index 77dce24..4eab7c2 100644
--- a/STYLE-GUIDE.txt
+++ b/STYLE-GUIDE.txt
@@ -43,8 +43,21 @@ usage_text() {
Executing Commands
==================
+When chaining commands look at `pipefail`.
+
* http://unix.stackexchange.com/q/23026
+If you want to fail this shell if a sub-shell fails, use this form:
+
+----------------------------------------------------------------------
+ENV=$(app conf get app.env) || false
+----------------------------------------------------------------------
+
+The sub-shell will exit with a non-zero exit code, but even with `-e`
+set bash won't exit the current shell.
+
+See also http://www.fvue.nl/wiki/Bash:_Error_handling.
+
Parsing options
===============
diff --git a/test/app-upgrade.bats b/test/app-upgrade.bats
index 9a282e3..28841f3 100755
--- a/test/app-upgrade.bats
+++ b/test/app-upgrade.bats
@@ -58,13 +58,12 @@ load utils
# Try to reinstall the same file
rm fail-pre-install
app upgrade
- eq '${lines[0]}' "Resolving version "
- eq '${lines[1]}' "Resolved version to 1359766920"
- eq '${lines[2]}' "Version 1359766920 is already unpacked"
- eq '${lines[3]}' "Importing config from versions/1359766920/app.config"
- eq '${lines[4]}' "pre-install"
- eq '${lines[5]}' "Changing current symlink from 1356998460 to 1359766920"
- eq '${lines[6]}' "post-install"
-
+ eq '${lines[0]}' "Resolving version "
+ eq '${lines[1]}' "Resolved version to 1359766920"
+ eq '${lines[2]}' "Version 1359766920 is already unpacked"
+ eq '${lines[3]}' "Importing config from versions/1359766920/app.config"
+ eq '${lines[4]}' "pre-install"
+ eq '${lines[5]}' "Changing current symlink from 1356998460 to 1359766920"
+ eq '${lines[6]}' "post-install"
eq '${#lines[*]}' 7
}