From 234bf6293a564e99333404eee4a8c2b27f7a5123 Mon Sep 17 00:00:00 2001 From: Jeff Bilyk Date: Thu, 23 Dec 2010 20:02:10 +0000 Subject: apts: update README, add comments to apts script update README and add comments to script --- README | 2 +- apts | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/README b/README index 101bd98..65ec551 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ Contributor: Natanael Copa 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. diff --git a/apts b/apts index 95eb662..eb8128d 100755 --- a/apts +++ b/apts @@ -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 - -- cgit v1.2.3