Commit | Line | Data |
---|---|---|
370d150f SM |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) 2019 EfficiOS Inc. | |
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 | if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then | |
19 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" | |
20 | else | |
21 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" | |
22 | fi | |
23 | ||
24 | # shellcheck source=../../utils/utils.sh | |
25 | SH_TAP=1 source "$UTILSSH" | |
26 | ||
27 | plan_tests 3 | |
28 | ||
29 | data_dir="${BT_TESTS_DATADIR}/cli/list-plugins" | |
30 | plugin_dir="${data_dir}" | |
31 | ||
32 | stdout_file=$(mktemp -t test_cli_list_plugins_stdout.XXXXXX) | |
33 | stderr_file=$(mktemp -t test_cli_list_plugins_stderr.XXXXXX) | |
34 | grep_stdout_file=$(mktemp -t test_cli_list_plugins_grep_stdout.XXXXXX) | |
35 | py_plugin_expected_stdout_file=$(mktemp -t test_cli_list_plugins_expected_py_plugin_stdout.XXXXXX) | |
36 | ||
37 | # Run list-plugins. | |
38 | bt_cli "$stdout_file" "$stderr_file" \ | |
39 | --plugin-path "$plugin_dir" \ | |
40 | list-plugins | |
41 | ok "$?" "exit code is 0" | |
42 | ||
43 | # Extract the section about our custom this-is-a-plugin Python plugin. | |
44 | grep --after-context=11 '^this-is-a-plugin:$' "${stdout_file}" > "${grep_stdout_file}" | |
45 | ok "$?" "entry for this-is-a-plugin is present" | |
46 | ||
47 | if [ "$BT_OS_TYPE" = "mingw" ]; then | |
48 | platform_plugin_dir=$(cygpath -m "${plugin_dir}") | |
49 | else | |
50 | platform_plugin_dir="${plugin_dir}" | |
51 | fi | |
52 | ||
53 | # Generate the expected output file for that plugin. | |
54 | cat <<- EOF > "${py_plugin_expected_stdout_file}" | |
55 | this-is-a-plugin: | |
56 | Path: ${platform_plugin_dir}/bt_plugin_list_plugins.py | |
57 | Version: 1.2.3bob | |
58 | Description: A plugin | |
59 | Author: Jorge Mario Bergoglio | |
60 | License: The license | |
61 | Source component classes: | |
62 | 'source.this-is-a-plugin.ThisIsASource' | |
63 | Filter component classes: | |
64 | 'filter.this-is-a-plugin.ThisIsAFilter' | |
65 | Sink component classes: | |
66 | 'sink.this-is-a-plugin.ThisIsASink' | |
67 | EOF | |
68 | ||
69 | # Compare the entry for this-is-a-plugin with the expected version. | |
70 | bt_diff "${py_plugin_expected_stdout_file}" "${grep_stdout_file}" | |
71 | ok "$?" "entry for this-is-a-plugin is as expected" | |
72 | ||
73 | rm -f "${stdout_file}" | |
74 | rm -f "${stderr_file}" | |
75 | rm -f "${grep_stdout_file}" | |
76 | rm -f "${py_plugin_expected_stdout_file}" |