diff options
-rw-r--r-- | README | 2 | ||||
-rwxr-xr-x | apts | 30 |
2 files changed, 26 insertions, 6 deletions
@@ -3,7 +3,7 @@ Contributor: Natanael Copa <ncopa@alpinelinux.org> Version: 0.1 APTS is designed to allow testing of either entire repositories of apk packages -or one by one. +or one by one. When an error is encountered, the program exits with an error. The file missing-tests shows current packages that do not have a test file created for them. @@ -39,22 +39,38 @@ shift # Get directory with test files . /etc/apts/apts.conf +# Check that TESTSDIR exists before proceeding +test -e $TESTSDIR +if [ $? -gt 0 ]; then + echo "Test file directory $TESTSDIR doesn't exit" && exit 1; +fi + # CD to test file dir cd $TESTSDIR # if there aren't any args besides outfile test all packages if [ $# -eq 0 ]; then - i=1 + + # Initialize counter + i=1 + + # Get total number of packages for status counters totaltests=`ls ./tests/ | wc -w` echo "All (${totaltests}) packages to be tested" passedtests="0" for package in `ls ./tests/`; do echo "Testing $package apk (${i}/${totaltests})" + + # Increment counter for tested packages i=$((i + 1)) /bin/sh -e ./tests/$package $package >> "$OUTFILE" 2>&1 + + # If exit code is non-zero, exit apts if [ $? -gt 0 ]; then echo "$package failed tests" && exit 1; fi + + # Log to both outfile and stdout echo "$package passed tests" >> "$OUTFILE" echo "$package passed tests" passedtests=$((passedtests + 1)) @@ -65,8 +81,10 @@ fi # If script still running, there's args, so test all specified packages i=1 + +# Loop through all packages specified while [ $# -gt 0 ]; do - echo "file number $i: $1" + echo "Package $i: $1" PACKAGE=$1 # does testing file exist @@ -76,7 +94,8 @@ while [ $# -gt 0 ]; do if [ "$?" == "1" ]; then echo "Testing file for $PACKAGE does not exist" /bin/sh -e ./tests/generic-apk $PACKAGE >> "$OUTFILE" 2>&1 - + + # If exit code is non-zero, exit apts if [ $? -gt 0 ]; then echo "$PACKAGE failed tests" && exit 1; fi @@ -88,14 +107,15 @@ while [ $# -gt 0 ]; do echo "Testing $PACKAGE apk" /bin/sh -e ./tests/$PACKAGE $PACKAGE >> "$OUTFILE" 2>&1 + # If exit code is non-zero, exit apts if [ $? -gt 0 ]; then echo "$PACKAGE failed tests" && exit 1; fi echo "$PACKAGE passed tests" fi - + + # Increment counter and shift to next arg i=$((i + 1)) shift done - |