Merge pull request #734 from matthiasbeyer/test-via-makefile

Execute tests via Makefile
This commit is contained in:
Matthias Beyer 2016-09-20 10:20:59 +02:00 committed by GitHub
commit 050aec2aa1
4 changed files with 44 additions and 13 deletions

View file

@ -21,18 +21,9 @@ before_script:
script: script:
- | - |
if [[ "$TEST_SUITE" == "binaries" ]]; then if [[ "$TEST_SUITE" == "binaries" ]]; then
make $(find . -maxdepth 1 -name "imag-*" -type d -printf "%f ") && \ make bin-test
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
else # $TEST_SUITE == "libraries" else # $TEST_SUITE == "libraries"
make $(find . -maxdepth 1 -name "libimag*" -printf "test-%f ") make lib-test
fi fi
addons: addons:

View file

@ -4,14 +4,17 @@ bin = $@/target/debug/$@
doc-crate-toml=./.imag-documentation/Cargo.toml doc-crate-toml=./.imag-documentation/Cargo.toml
ECHO=$(shell which echo) -e ECHO=$(shell which echo) -e
MAKE=$(shell which make)
BASH=$(shell which bash)
CARGO=$(shell which cargo) CARGO=$(shell which cargo)
BINS=$(shell find -maxdepth 1 -name "imag-*" -type d) BINS=$(shell find -maxdepth 1 -name "imag-*" -type d)
LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d) LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d)
BIN_TARGETS=$(patsubst imag-%,,$(BINS)) BIN_TARGETS=$(patsubst imag-%,,$(BINS))
BIN_TARGET_TESTS=$(foreach x,$(BIN_TARGETS),$(x)-test)
LIB_TARGETS=$(LIBS) 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) TARGETS=$(BIN_TARGETS) $(LIB_TARGETS)
RELEASE_TARGETS=$(foreach x,$(TARGETS),$(x)-release) RELEASE_TARGETS=$(foreach x,$(TARGETS),$(x)-release)
INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install) INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install)
@ -47,11 +50,15 @@ release: $(RELEASE_TARGETS) imag-bin-release
bin: $(BIN_TARGETS) imag-bin bin: $(BIN_TARGETS) imag-bin
@$(ECHO) "\t[ALLBIN ]" @$(ECHO) "\t[ALLBIN ]"
bin-test: $(BIN_TARGET_TESTS)
lib: $(LIB_TARGETS) lib: $(LIB_TARGETS)
@$(ECHO) "\t[ALLLIB ]" @$(ECHO) "\t[ALLLIB ]"
lib-test: $(LIB_TARGETS_TEST) lib-test: $(LIB_TARGETS_TEST)
test: bin-test lib-test
install: $(INSTALL_TARGETS) install: $(INSTALL_TARGETS)
@$(ECHO) "\t[INSTALL]" @$(ECHO) "\t[INSTALL]"
@ -65,13 +72,19 @@ $(TARGETS): %: .FORCE
@$(ECHO) "\t[CARGO ]:\t$@" @$(ECHO) "\t[CARGO ]:\t$@"
@$(CARGO) build --manifest-path ./$@/Cargo.toml @$(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 $(RELEASE_TARGETS): %: .FORCE
@$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)" @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)"
@$(CARGO) build --release --manifest-path ./$(subst -release,,$@)/Cargo.toml @$(CARGO) build --release --manifest-path ./$(subst -release,,$@)/Cargo.toml
$(LIB_TARGETS_TEST): %: .FORCE $(LIB_TARGETS_TEST): %: .FORCE
@$(ECHO) "\t[TEST ]:\t$@" @$(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 $(INSTALL_TARGETS): %: .FORCE imag-bin-install
@$(ECHO) "\t[INSTALL]:\t$(subst -install,,$@)" @$(ECHO) "\t[INSTALL]:\t$(subst -install,,$@)"

13
imag-link/tests/Makefile Normal file
View file

@ -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:

14
imag-store/tests/Makefile Normal file
View file

@ -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: