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 | ||
b6a0ac97 | 34 | data_dir="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-params-log-level" |
459f81ca SM |
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 | ||
b6a0ac97 SM |
43 | print_test_params="--params print=\"test-params\"" |
44 | ||
459f81ca SM |
45 | # Apply params to two components from one leftover. |
46 | cat > "$expected_file" <<END | |
47 | TestSourceA: ('test-allo', 'madame') | |
48 | TestSourceB: ('test-allo', 'madame') | |
49 | END | |
50 | ||
51 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
52 | convert --plugin-path "${plugin_dir}" \ | |
b6a0ac97 | 53 | "${dir_ab}" --params 'test-allo="madame"' ${print_test_params} |
459f81ca SM |
54 | ok "$?" "apply params to two components from one leftover" |
55 | ||
56 | # Apply params to two components from two distinct leftovers. | |
57 | cat > "$expected_file" <<END | |
58 | TestSourceA: ('test-allo', 'madame') | |
59 | TestSourceB: ('test-bonjour', 'monsieur') | |
60 | END | |
61 | ||
62 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
63 | convert --plugin-path "${plugin_dir}" \ | |
b6a0ac97 | 64 | "${dir_a}" --params 'test-allo="madame"' ${print_test_params} "${dir_b}" --params 'test-bonjour="monsieur"' ${print_test_params} |
459f81ca SM |
65 | ok "$?" "apply params to two leftovers" |
66 | ||
67 | # Apply params to one component coming from one leftover and one component coming from two leftovers (1). | |
68 | cat > "$expected_file" <<END | |
69 | TestSourceA: ('test-allo', 'madame'), ('test-bonjour', 'monsieur') | |
70 | TestSourceB: ('test-bonjour', 'monsieur') | |
71 | END | |
72 | ||
73 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
74 | convert --plugin-path "${plugin_dir}" \ | |
b6a0ac97 | 75 | "${dir_a}" --params 'test-allo="madame"' ${print_test_params} "${dir_ab}" --params 'test-bonjour="monsieur"' ${print_test_params} |
459f81ca SM |
76 | ok "$?" "apply params to one component coming from one leftover and one component coming from two leftovers (1)" |
77 | ||
78 | # Apply params to one component coming from one leftover and one component coming from two leftovers (2). | |
79 | cat > "$expected_file" <<END | |
80 | TestSourceA: ('test-bonjour', 'monsieur'), ('test-salut', 'les amis') | |
81 | TestSourceB: ('test-bonjour', 'madame'), ('test-salut', 'les amis') | |
82 | END | |
83 | ||
84 | bt_diff_cli_sorted "$expected_file" "$stderr_expected" \ | |
85 | convert --plugin-path "${plugin_dir}" \ | |
b6a0ac97 | 86 | "${dir_ab}" --params 'test-bonjour="madame",test-salut="les amis"' ${print_test_params} "${dir_a}" --params 'test-bonjour="monsieur"' ${print_test_params} |
459f81ca SM |
87 | ok "$?" "apply params to one component coming from one leftover and one component coming from two leftovers (2)" |
88 | ||
89 | rm -f "$expected_file" |