commit: e046d875a0bc655c522fc30760e61c8b2b3408d8
Author: Virgil Dupras <hsoft <AT> hardcoded <DOT> net>
AuthorDate: Wed Aug 15 14:26:51 2018 +0000
Commit: Virgil Dupras <vdupras <AT> gentoo <DOT> org>
CommitDate: Wed Aug 15 14:26:51 2018 +0000
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e046d875
Add functional tests through "cmdtests"
These tests run a list of commands on both the system gentoolkit and the
source from the active work directory, and then compares the results.
It's a great way to verify that a refactoring didn't introduce an
unwanted change in behavior.
cmdtests/README.txt | 16 ++++++++++++++++
cmdtests/cmds.txt | 3 +++
cmdtests/runtests.sh | 21 +++++++++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/cmdtests/README.txt b/cmdtests/README.txt
new file mode 100644
index 0000000..192a7fc
--- /dev/null
+++ b/cmdtests/README.txt
@@ -0,0 +1,16 @@
+Use the "runtests.sh" script to test the output of all commands in "cmds.txt"
+against the output that the version of gentoolkit installed on the system
+yields.
+
+It's a great way to verify that a refactoring didn't affect output.
+
+Usage:
+
+$ cd cmdtests
+$ ./runtests.sh
+
+You can also test against a specific version of gentoolkit instead. Clone a
+copy of gentoolkit to test against and then do:
+
+$ cd cmdtests
+$ ./runtests.sh /path/to/othergentoolkit/pym
diff --git a/cmdtests/cmds.txt b/cmdtests/cmds.txt
new file mode 100644
index 0000000..38ebb2e
--- /dev/null
+++ b/cmdtests/cmds.txt
@@ -0,0 +1,3 @@
+equery meta dev-lang/python
+equery d -a llvm
+equery l "vim*"
diff --git a/cmdtests/runtests.sh b/cmdtests/runtests.sh
new file mode 100755
index 0000000..ba0ff22
--- /dev/null
+++ b/cmdtests/runtests.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+TEST_AGAINST_PYTHON_PATH=$1
+
+while read -r line; do
+ echo "Running $line > before"
+ PYTHONPATH="${TEST_AGAINST_PYTHON_PATH}"
+ eval "$line" > before || exit 1
+ echo "Running $line > after"
+ PYTHONPATH="../pym"
+ eval "$line" > after || exit 1
+ DIFF=$(diff -u before after)
+ if [[ -n $DIFF ]]; then
+ echo "Different!"
+ echo "$DIFF"
+ exit 1
+ fi
+done < cmds.txt
+
+rm before after
+echo "All commands output the exact same thing!"