Hello Stefan.petrea,
I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/98523
to review the following change.
Change subject: Add rudimentary test accounting to current tests
......................................................................
Add rudimentary test accounting to current tests
Change-Id: I13f787fe25620acf7e0c24d1e395a121c382a752
---
M tests/test.sh
1 file changed, 56 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/analytics/webstatscollector
refs/changes/23/98523/1
diff --git a/tests/test.sh b/tests/test.sh
index c4c4615..ec212cc 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -1,33 +1,81 @@
#!/bin/bash
FILTER="../filter"
+TESTS=0
+TESTS_GOOD=0
+FIRST_FAILED_TEST_NAME=
+
+start_test() {
+ local NAME="$1"
+
+ TESTS=$((TESTS+1))
+ CURRENT_TEST_NAME="$NAME"
+
+ echo -n "Test #${TESTS}: ${CURRENT_TEST_NAME} ... "
+}
+
+mark_test_passed() {
+ TESTS_GOOD=$((TESTS_GOOD+1))
+ echo "pass"
+}
+
+mark_test_failed() {
+ echo "FAIL!"
+ if [ -z "$FIRST_FAILED_TEST_NAME" ]
+ then
+ FIRST_FAILED_TEST_NAME="$CURRENT_TEST_NAME"
+ FIRST_FAILED_TEST_NUMBER="$TESTS"
+ fi
+}
+
+start_test "Spaceless lines in filter"
#----------------------------------------
TEST_SPACELESS_LINES=`cat entries-with-urls-with-spaces-2013-02-10.txt |
"$FILTER" | perl -MData::Dumper -ne '@f=split(/\s/,$_,4); print if $f[3] =~ /\
/;' | wc -l`
-
if [ $TEST_SPACELESS_LINES -eq 0 ]; then
- echo "Test1: Spaceless lines in filter PASSED";
+ mark_test_passed
else
- echo "Test1: Spaceless lines in filter FAILED";
+ mark_test_failed
exit -1;
fi
+start_test "Big fields in filter"
#---------------------------------------------
trap "" SIGSEGV
cat big-entry-1.txt | "$FILTER" >/dev/null 2>/dev/null
if [ $? -ne 139 ]; then
- echo "Test2: Big fields in filter PASSED";
+ mark_test_passed
else
- echo "Test2: Big fields in filter FAILED";
+ mark_test_failed
fi
+start_test "in->project is empty"
#---------------------------------------------
TEST_PROJECT_EMPTY=`cat entry-line1.txt | "$FILTER" | wc -l`;
if [ $? -ne 139 -a $TEST_PROJECT_EMPTY -eq 0 ]; then
- echo "Test3: in->project is empty PASSED";
+ mark_test_passed
else
- echo "Test3: in->project is empty FAILED";
+ mark_test_failed
fi
+# -- printing statistics
-------------------------------------------------------
-# test
+TESTS_FAILED=$((TESTS-TESTS_GOOD))
+
+if [ $TESTS_FAILED -eq 0 ]
+then
+ TESTS_FAILED_APPENDIX=
+else
+ TESTS_FAILED_APPENDIX=" (first failed test is
#${FIRST_FAILED_TEST_NUMBER}: '$FIRST_FAILED_TEST_NAME')"
+fi
+
+cat <<EOF
+
+Test statistics:
+ # of tests : ${TESTS}
+ # of passed tests : ${TESTS_GOOD}
+ # of failed tests : ${TESTS_FAILED}${TESTS_FAILED_APPENDIX}
+
+EOF
+
+exit $TESTS_FAILED
--
To view, visit https://gerrit.wikimedia.org/r/98523
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I13f787fe25620acf7e0c24d1e395a121c382a752
Gerrit-PatchSet: 1
Gerrit-Project: analytics/webstatscollector
Gerrit-Branch: master
Gerrit-Owner: QChris <[email protected]>
Gerrit-Reviewer: Stefan.petrea <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits