From 563fc66cbd27d76b6f851e9dc35301f1cd3b012d Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Tue, 10 May 2016 14:10:36 +0200 Subject: [PATCH] Add a few automated tests. --- .travis.yml | 1 + tests.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .travis.yml create mode 100644 tests.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d3591ac --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +script: sh tests.sh diff --git a/tests.sh b/tests.sh new file mode 100644 index 0000000..c8d6603 --- /dev/null +++ b/tests.sh @@ -0,0 +1,45 @@ +UPSTREAM=https://github.com/larsbrinkhoff/awesome-cpus +MAX_DIR_SIZE=27000 + +error() { + echo + echo "ERROR: $1" + exit 1 +} + +test_directory_size() { + echo -n "Checking that no directory is too large... " + + git submodule deinit . > /dev/null + du -s * | while read i; do + set $i + if test "$1" -gt $MAX_DIR_SIZE; then + error "The $2 directory is too large" + fi + done + + echo OK +} + +directories_in_commit() { + git show --name-only --format=format: "$1" | grep / | wc -l +} + +test_commits() { + echo -n "Checking that each commit touches only one directory... " + + git remote add github-upstream $UPSTREAM + git log --format="format:%H%n" origin/master..HEAD | while read i; do + if test `directories_in_commit "$i"` -gt 1; then + h=`echo "$i" | cut -c1-7` + error "Commit $h touches more than one directory." + fi + done + git remote remove github-upstream + + echo OK +} + +test_directory_size +test_commits +