Gentoo Archives: gentoo-commits

From: Virgil Dupras <vdupras@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoolkit:master commit in: cmdtests/
Date: Wed, 15 Aug 2018 19:16:55
Message-Id: 1534343211.e046d875a0bc655c522fc30760e61c8b2b3408d8.vdupras@gentoo
1 commit: e046d875a0bc655c522fc30760e61c8b2b3408d8
2 Author: Virgil Dupras <hsoft <AT> hardcoded <DOT> net>
3 AuthorDate: Wed Aug 15 14:26:51 2018 +0000
4 Commit: Virgil Dupras <vdupras <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 15 14:26:51 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e046d875
7
8 Add functional tests through "cmdtests"
9
10 These tests run a list of commands on both the system gentoolkit and the
11 source from the active work directory, and then compares the results.
12
13 It's a great way to verify that a refactoring didn't introduce an
14 unwanted change in behavior.
15
16 cmdtests/README.txt | 16 ++++++++++++++++
17 cmdtests/cmds.txt | 3 +++
18 cmdtests/runtests.sh | 21 +++++++++++++++++++++
19 3 files changed, 40 insertions(+)
20
21 diff --git a/cmdtests/README.txt b/cmdtests/README.txt
22 new file mode 100644
23 index 0000000..192a7fc
24 --- /dev/null
25 +++ b/cmdtests/README.txt
26 @@ -0,0 +1,16 @@
27 +Use the "runtests.sh" script to test the output of all commands in "cmds.txt"
28 +against the output that the version of gentoolkit installed on the system
29 +yields.
30 +
31 +It's a great way to verify that a refactoring didn't affect output.
32 +
33 +Usage:
34 +
35 +$ cd cmdtests
36 +$ ./runtests.sh
37 +
38 +You can also test against a specific version of gentoolkit instead. Clone a
39 +copy of gentoolkit to test against and then do:
40 +
41 +$ cd cmdtests
42 +$ ./runtests.sh /path/to/othergentoolkit/pym
43
44 diff --git a/cmdtests/cmds.txt b/cmdtests/cmds.txt
45 new file mode 100644
46 index 0000000..38ebb2e
47 --- /dev/null
48 +++ b/cmdtests/cmds.txt
49 @@ -0,0 +1,3 @@
50 +equery meta dev-lang/python
51 +equery d -a llvm
52 +equery l "vim*"
53
54 diff --git a/cmdtests/runtests.sh b/cmdtests/runtests.sh
55 new file mode 100755
56 index 0000000..ba0ff22
57 --- /dev/null
58 +++ b/cmdtests/runtests.sh
59 @@ -0,0 +1,21 @@
60 +#!/bin/bash
61 +
62 +TEST_AGAINST_PYTHON_PATH=$1
63 +
64 +while read -r line; do
65 + echo "Running $line > before"
66 + PYTHONPATH="${TEST_AGAINST_PYTHON_PATH}"
67 + eval "$line" > before || exit 1
68 + echo "Running $line > after"
69 + PYTHONPATH="../pym"
70 + eval "$line" > after || exit 1
71 + DIFF=$(diff -u before after)
72 + if [[ -n $DIFF ]]; then
73 + echo "Different!"
74 + echo "$DIFF"
75 + exit 1
76 + fi
77 +done < cmds.txt
78 +
79 +rm before after
80 +echo "All commands output the exact same thing!"