forked from Narigo/keepass-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·83 lines (66 loc) · 3.55 KB
/
run-tests.sh
File metadata and controls
executable file
·83 lines (66 loc) · 3.55 KB
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
#!/usr/bin/env bash
(
set -e
test_equal() {
if [ "$2" == "$3" ]; then
echo "✅ $1"
else
echo "❌ $1"
echo "$2"
echo " -> "
echo "$3"
exit 1
fi
}
test_gt() {
if [ "$2" -gt "$3" ]; then
echo "✅ $1"
else
echo "❌ $1"
echo "$2"
echo " is smaller or equal to "
echo "$3"
exit 1
fi
}
echo "### Running verbose equality tests, depending on order"
echo "# Run a <diff> b"
cargo run "$PWD/test/test.kdbx" "$PWD/test/test2.kdbx" --passwords demopass --no-color --verbose >"$PWD/target/test-result-01.txt"
echo "# Run b <diff> a"
cargo run "$PWD/test/test2.kdbx" "$PWD/test/test.kdbx" --passwords demopass --no-color --verbose >"$PWD/target/test-result-02.txt"
lines_of_run_01=$(cat target/test-result-01.txt | wc -l)
lines_of_run_02=$(cat target/test-result-02.txt | wc -l)
test_equal "first run should have same amount of lines as second run" $lines_of_run_01 $lines_of_run_02
amount_of_plus_01=$(cat target/test-result-01.txt | grep '^+' | wc -l)
amount_of_minus_01=$(cat target/test-result-01.txt | grep '^-' | wc -l)
amount_of_tilde_01=$(cat target/test-result-01.txt | grep '^~' | wc -l)
amount_of_plus_02=$(cat target/test-result-02.txt | grep '^+' | wc -l)
amount_of_minus_02=$(cat target/test-result-02.txt | grep '^-' | wc -l)
amount_of_tilde_02=$(cat target/test-result-02.txt | grep '^~' | wc -l)
test_gt "should output more than 0 plus lines" $amount_of_plus_01 0
test_gt "should output more than 0 minus lines" $amount_of_minus_01 0
test_gt "should output more than 0 tilde lines" $amount_of_tilde_01 0
test_equal "first run should have same amount of tilde lines as second run" $amount_of_tilde_01 $amount_of_tilde_02
test_equal "first run should have same amount of plus lines as second run has minus lines" $amount_of_plus_01 $amount_of_minus_02
test_equal "first run should have same amount of minus lines as second run has plus lines" $amount_of_minus_01 $amount_of_plus_02
echo "### Running regular equality tests, depending on order"
echo "# Run a <diff> b"
cargo run "$PWD/test/test.kdbx" "$PWD/test/test2.kdbx" --passwords demopass --no-color >"$PWD/target/test-result-03.txt"
echo "# Run b <diff> a"
cargo run "$PWD/test/test2.kdbx" "$PWD/test/test.kdbx" --passwords demopass --no-color >"$PWD/target/test-result-04.txt"
lines_of_run_03=$(cat target/test-result-03.txt | wc -l)
lines_of_run_04=$(cat target/test-result-04.txt | wc -l)
test_equal "first run should have same amount of lines as second run" $lines_of_run_03 $lines_of_run_04
amount_of_plus_03=$(cat target/test-result-03.txt | grep '^+' | wc -l)
amount_of_minus_03=$(cat target/test-result-03.txt | grep '^-' | wc -l)
amount_of_tilde_03=$(cat target/test-result-03.txt | grep '^~' | wc -l)
amount_of_plus_04=$(cat target/test-result-04.txt | grep '^+' | wc -l)
amount_of_minus_04=$(cat target/test-result-04.txt | grep '^-' | wc -l)
amount_of_tilde_04=$(cat target/test-result-04.txt | grep '^~' | wc -l)
test_gt "should output more than 0 plus lines" $amount_of_plus_03 0
test_gt "should output more than 0 minus lines" $amount_of_minus_03 0
test_equal "should output 0 tilde lines" $amount_of_tilde_03 0
test_equal "should output 0 tilde lines in second run as well" $amount_of_tilde_04 0
test_equal "first run should have same amount of plus lines as second run has minus lines" $amount_of_plus_03 $amount_of_minus_04
test_equal "first run should have same amount of minus lines as second run has plus lines" $amount_of_minus_03 $amount_of_plus_04
)