Commit | Line | Data |
---|---|---|
459f81ca SM |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com> | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or modify it | |
6 | # under the terms of the GNU General Public License, version 2 only, as | |
7 | # published by the Free Software Foundation. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | # more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License along with | |
15 | # this program; if not, write to the Free Software Foundation, Inc., 51 | |
16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | ||
18 | # Test how parameters are applied to sources auto-discovered by the convert | |
19 | # command. | |
20 | ||
21 | if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then | |
22 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" | |
23 | else | |
24 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" | |
25 | fi | |
26 | ||
27 | # shellcheck source=../../utils/utils.sh | |
28 | SH_TAP=1 source "$UTILSSH" | |
29 | ||
30 | NUM_TESTS=4 | |
31 | ||
32 | plan_tests $NUM_TESTS | |
33 | ||
34 | data_dir="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-params" | |
35 | plugin_dir="${data_dir}" | |
36 | dir_a="${data_dir}/dir-a" | |
37 | dir_b="${data_dir}/dir-b" | |
38 | dir_ab="${data_dir}/dir-ab" | |
39 | ||
40 | expected_file=$(mktemp -t expected.XXXXXX) | |
41 | stderr_expected=/dev/null | |
42 | ||
43 | # Apply params to two components from one leftover. | |
44 | cat > "$expected_file" <<END | |
45 | TestSourceA: ('test-allo', 'madame') | |
46 | TestSourceB: ('test-allo', 'madame') | |
47 | END | |
48 | ||
49 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
50 | convert --plugin-path "${plugin_dir}" \ | |
51 | "${dir_ab}" --params 'test-allo="madame"' | |
52 | ok "$?" "apply params to two components from one leftover" | |
53 | ||
54 | # Apply params to two components from two distinct leftovers. | |
55 | cat > "$expected_file" <<END | |
56 | TestSourceA: ('test-allo', 'madame') | |
57 | TestSourceB: ('test-bonjour', 'monsieur') | |
58 | END | |
59 | ||
60 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
61 | convert --plugin-path "${plugin_dir}" \ | |
62 | "${dir_a}" --params 'test-allo="madame"' "${dir_b}" --params 'test-bonjour="monsieur"' | |
63 | ok "$?" "apply params to two leftovers" | |
64 | ||
65 | # Apply params to one component coming from one leftover and one component coming from two leftovers (1). | |
66 | cat > "$expected_file" <<END | |
67 | TestSourceA: ('test-allo', 'madame'), ('test-bonjour', 'monsieur') | |
68 | TestSourceB: ('test-bonjour', 'monsieur') | |
69 | END | |
70 | ||
71 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
72 | convert --plugin-path "${plugin_dir}" \ | |
73 | "${dir_a}" --params 'test-allo="madame"' "${dir_ab}" --params 'test-bonjour="monsieur"' | |
74 | ok "$?" "apply params to one component coming from one leftover and one component coming from two leftovers (1)" | |
75 | ||
76 | # Apply params to one component coming from one leftover and one component coming from two leftovers (2). | |
77 | cat > "$expected_file" <<END | |
78 | TestSourceA: ('test-bonjour', 'monsieur'), ('test-salut', 'les amis') | |
79 | TestSourceB: ('test-bonjour', 'madame'), ('test-salut', 'les amis') | |
80 | END | |
81 | ||
82 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
83 | convert --plugin-path "${plugin_dir}" \ | |
84 | "${dir_ab}" --params 'test-bonjour="madame",test-salut="les amis"' "${dir_a}" --params 'test-bonjour="monsieur"' | |
85 | ok "$?" "apply params to one component coming from one leftover and one component coming from two leftovers (2)" | |
86 | ||
87 | rm -f "$expected_file" |