diff --git a/.travis.yml b/.travis.yml index 633b0edb..365c9971 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,18 +21,9 @@ before_script: script: - | if [[ "$TEST_SUITE" == "binaries" ]]; then - make $(find . -maxdepth 1 -name "imag-*" -type d -printf "%f ") && \ - for d in $(find -name "Cargo.toml" | grep -vE "^./Cargo.toml$"); do - dir=$(dirname $d) - echo "--- Running test scripts ---" - for testsh in $(find $dir -iname "*test.sh"); do - echo "--- Running test script: '$testsh'" - bash $testsh || { echo "--- Test failed. Exiting"; exit 1; } - echo "--- Test script $testsh executed successfully" - done - done + make bin-test else # $TEST_SUITE == "libraries" - make $(find . -maxdepth 1 -name "libimag*" -printf "test-%f ") + make lib-test fi addons: diff --git a/Makefile b/Makefile index 1199a133..a2cc3059 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,17 @@ bin = $@/target/debug/$@ doc-crate-toml=./.imag-documentation/Cargo.toml ECHO=$(shell which echo) -e +MAKE=$(shell which make) +BASH=$(shell which bash) CARGO=$(shell which cargo) BINS=$(shell find -maxdepth 1 -name "imag-*" -type d) LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d) BIN_TARGETS=$(patsubst imag-%,,$(BINS)) +BIN_TARGET_TESTS=$(foreach x,$(BIN_TARGETS),$(x)-test) LIB_TARGETS=$(LIBS) -LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),test-$(x)) +LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),$(x)-test) TARGETS=$(BIN_TARGETS) $(LIB_TARGETS) RELEASE_TARGETS=$(foreach x,$(TARGETS),$(x)-release) INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install) @@ -47,11 +50,15 @@ release: $(RELEASE_TARGETS) imag-bin-release bin: $(BIN_TARGETS) imag-bin @$(ECHO) "\t[ALLBIN ]" +bin-test: $(BIN_TARGET_TESTS) + lib: $(LIB_TARGETS) @$(ECHO) "\t[ALLLIB ]" lib-test: $(LIB_TARGETS_TEST) +test: bin-test lib-test + install: $(INSTALL_TARGETS) @$(ECHO) "\t[INSTALL]" @@ -65,13 +72,19 @@ $(TARGETS): %: .FORCE @$(ECHO) "\t[CARGO ]:\t$@" @$(CARGO) build --manifest-path ./$@/Cargo.toml +$(BIN_TARGET_TESTS): %-test: % .FORCE + @$(ECHO) "\t[BINTEST]:\t$@" + if [[ -f $(subst -test,,$@)/tests/Makefile ]]; then \ + $(MAKE) -C $(subst -test,,$@)/tests || exit 1;\ + fi; + $(RELEASE_TARGETS): %: .FORCE @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)" @$(CARGO) build --release --manifest-path ./$(subst -release,,$@)/Cargo.toml $(LIB_TARGETS_TEST): %: .FORCE @$(ECHO) "\t[TEST ]:\t$@" - @$(CARGO) test --manifest-path ./$(subst test-,,$@)/Cargo.toml + @$(CARGO) test --manifest-path ./$(subst -test,,$@)/Cargo.toml $(INSTALL_TARGETS): %: .FORCE imag-bin-install @$(ECHO) "\t[INSTALL]:\t$(subst -install,,$@)" diff --git a/imag-link/tests/Makefile b/imag-link/tests/Makefile new file mode 100644 index 00000000..2713587a --- /dev/null +++ b/imag-link/tests/Makefile @@ -0,0 +1,13 @@ +ECHO=$(shell which echo) -e +TARGETS=$(shell find -name "*test.sh" -type f) +BASH=$(shell which bash) + +all: $(TARGETS) + @$(ECHO) $(TARGETS) + +$(TARGETS): %: .FORCE + @$(ECHO) "\t[BASH ]:\t$@" + @$(BASH) $@ + +.FORCE: + diff --git a/imag-store/tests/Makefile b/imag-store/tests/Makefile new file mode 100644 index 00000000..c58562d7 --- /dev/null +++ b/imag-store/tests/Makefile @@ -0,0 +1,14 @@ +ECHO=$(shell which echo) -e +TARGETS=$(shell find -name "*test.sh" -type f) +BASH=$(shell which bash) + +all: $(TARGETS) + @$(ECHO) $(TARGETS) + +$(TARGETS): %: .FORCE + @$(ECHO) "\t[BASH ]:\t$@" + @$(BASH) $@ + +.FORCE: + +