summaryrefslogtreecommitdiffstats
path: root/test/test_sadt
blob: 0292d20431164515bc3fa200e530976eab43bcd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh

# Copyright (C) 2018, Antonio Terceiro <terceiro@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

set -u

. ${0%/*}/test_helper.sh

if test "${1:-}" = --installed; then
    sadt="sadt"
    shift
else
    sadt="$(readlink -f "${0%/*}/../scripts/sadt")"
fi

samples="${0%/*}/sadt"

run_sadt() {
    dir="$1"
    shift
    (cd "$samples/$dir" && $sadt "$@")
}

test_passes() {
    assertPasses run_sadt passes
}

test_superficial() {
    assertPasses run_sadt superficial
    assertFails run_sadt superficial-fails
}

test_flaky() {
    assertPasses run_sadt flaky
}

test_skippable() {
    assertPasses run_sadt skippable
}

test_skippable_fails() {
    assertFails run_sadt unskippable
    assertFails run_sadt unskipped
}

test_fails() {
    assertFails run_sadt fails
}

test_space_separated_tests() {
    assertPasses run_sadt space-separated-tests
    assertFalse "skipped=1 found in output" "grep -q skipped=1 $log"
}

test_comma_separated_tests() {
    assertPasses run_sadt comma-separated-tests
    assertFalse "skipped=1 found in output" "grep -q skipped=1 $log"
}

test_space_separated_restrictions() {
    assertPasses run_sadt space-separated-restrictions
    assertFalse "skipped=1 found in output" "grep -q skipped=1 $log"
}

test_comma_separated_restrictions() {
    assertPasses run_sadt comma-separated-restrictions
    assertFalse "skipped=1 found in output" "grep -q skipped=1 $log"
}

test_tests_directory() {
    assertPasses run_sadt tests-directory
    assertFalse "skipped=1 found in output" "grep -q skipped=1 $log"
}

test_test_command() {
    assertPasses run_sadt test-command --verbose
    assertTrue "recognizes Test-Command" "grep 'O: Test-Command is supported' $log"
    assertTrue "recognizes Test-Command" "grep tests=1 $log"
}

test_run_specific_tests() {
    assertPasses run_sadt comma-separated-tests --verbose test1
    assertTrue "runs test1" "grep '^test1:' $log"
    assertFalse "does not run test2" "grep '^test2:' $log"
}

. shunit2