mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2024-12-19 05:34:33 +00:00
tests: Switch to kyua/atf-test, add tests for functions.sh
This commit is contained in:
parent
4d3c8c8533
commit
9dc6b74058
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
*.o
|
||||
*.1
|
||||
*.5
|
||||
Kyuafile
|
||||
abuild
|
||||
abuild-fetch
|
||||
abuild-gzsplit
|
||||
|
18
Makefile
18
Makefile
@ -78,7 +78,7 @@ P=$(PACKAGE)-$(VERSION)
|
||||
all: $(USR_BIN_FILES) $(MAN_PAGES) functions.sh
|
||||
|
||||
clean:
|
||||
@rm -f $(USR_BIN_FILES) $(MAN_PAGES) *.o functions.sh
|
||||
@rm -f $(USR_BIN_FILES) $(MAN_PAGES) *.o functions.sh Kyuafile tests/Kyuafile
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -c $<
|
||||
@ -102,8 +102,20 @@ help:
|
||||
@echo "$(P) makefile"
|
||||
@echo "usage: make install [ DESTDIR=<path> ]"
|
||||
|
||||
check: $(USR_BIN_FILE) functions.sh
|
||||
cd tests && bats $${FILTER:+ --filter $$FILTER} *.bats
|
||||
tests/Kyuafile: $(wildcard tests/*_test)
|
||||
echo "syntax(2)" > $@
|
||||
echo "test_suite('abuild')" >> $@
|
||||
for i in $(notdir $(wildcard tests/*_test)); do \
|
||||
echo "atf_test_program{name='$$i',timeout=5}" >> $@ ; \
|
||||
done
|
||||
|
||||
Kyuafile: tests/Kyuafile
|
||||
echo "syntax(2)" > $@
|
||||
echo "test_suite('abuild')" >> $@
|
||||
echo "include('tests/Kyuafile')" >> $@
|
||||
|
||||
check: $(SCRIPTS) $(USR_BIN_FILES) functions.sh tests/Kyuafile Kyuafile
|
||||
kyua test || (kyua report --verbose && exit 1)
|
||||
|
||||
install: $(USR_BIN_FILES) $(SAMPLES) $(MAN_PAGES) abuild.conf functions.sh
|
||||
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
|
||||
|
27
tests/functions_test
Executable file
27
tests/functions_test
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
|
||||
. $(atf_get_srcdir)/test_env.sh
|
||||
init_tests \
|
||||
funcs_check_CBUILD \
|
||||
funcs_check_missing_gcc \
|
||||
funcs_check_missing_apk
|
||||
|
||||
FUNCS=$(atf_get_srcdir)/../functions.sh
|
||||
|
||||
funcs_check_CBUILD_body() {
|
||||
atf_check -s exit:0 \
|
||||
-o not-empty \
|
||||
-e empty \
|
||||
sh -e -c " . $FUNCS; echo \"\$CBUILD\""
|
||||
}
|
||||
|
||||
funcs_check_missing_gcc_body() {
|
||||
atf_check -s exit:0 \
|
||||
sh -e -c "CC=false; . $FUNCS && test -z \"$CBUILD\""
|
||||
}
|
||||
|
||||
funcs_check_missing_apk_body() {
|
||||
atf_check -s exit:1 \
|
||||
-e match:"Unable to deduce build architecture" \
|
||||
sh -e -c "APK=false; . $FUNCS && test -z \"$CBUILD\""
|
||||
}
|
15
tests/test_env.sh
Normal file
15
tests/test_env.sh
Normal file
@ -0,0 +1,15 @@
|
||||
PATH=$(atf_get_srcdir)/..:$PATH
|
||||
|
||||
init_tests() {
|
||||
TESTS="$@"
|
||||
export TESTS
|
||||
for t; do
|
||||
atf_test_case $t
|
||||
done
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
for t in $TESTS; do
|
||||
atf_add_test_case $t
|
||||
done
|
||||
}
|
Loading…
Reference in New Issue
Block a user