summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-12-05 12:28:01 -0800
committerGitHub <noreply@github.com>2022-12-05 12:28:01 -0800
commit79dfe14adffbfb17a16782e3370d212c878feeb2 (patch)
tree9f9e036d7948ee3f9f8d87ff6dda2b7bb8ea50e2
parent31f9d60b8d00452c96ebec423c6a263b9d2eebd7 (diff)
downloadansible-79dfe14adffbfb17a16782e3370d212c878feeb2.tar.gz
More integration tests for import sanity test. (#79532)
-rw-r--r--test/integration/targets/ansible-test-sanity-import/expected.txt2
-rwxr-xr-xtest/integration/targets/ansible-test-sanity-import/runme.sh22
2 files changed, 24 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-test-sanity-import/expected.txt b/test/integration/targets/ansible-test-sanity-import/expected.txt
new file mode 100644
index 0000000000..ab41fd78aa
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-import/expected.txt
@@ -0,0 +1,2 @@
+plugins/lookup/stderr.py:0:0: stderr: unwanted stderr
+plugins/lookup/stdout.py:0:0: stdout: unwanted stdout
diff --git a/test/integration/targets/ansible-test-sanity-import/runme.sh b/test/integration/targets/ansible-test-sanity-import/runme.sh
index a12e3e3fd2..a49a71a0f0 100755
--- a/test/integration/targets/ansible-test-sanity-import/runme.sh
+++ b/test/integration/targets/ansible-test-sanity-import/runme.sh
@@ -1,7 +1,29 @@
#!/usr/bin/env bash
+set -eu
+
+# Create test scenarios at runtime that do not pass sanity tests.
+# This avoids the need to create ignore entries for the tests.
+
+mkdir -p ansible_collections/ns/col/plugins/lookup
+
+(
+ cd ansible_collections/ns/col/plugins/lookup
+
+ echo "import sys; sys.stdout.write('unwanted stdout')" > stdout.py # stdout: unwanted stdout
+ echo "import sys; sys.stderr.write('unwanted stderr')" > stderr.py # stderr: unwanted stderr
+)
+
source ../collection/setup.sh
+# Run regular import sanity tests.
+
+ansible-test sanity --test import --color --failure-ok --lint --python "${ANSIBLE_TEST_PYTHON_VERSION}" "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
+diff -u "${TEST_DIR}/expected.txt" actual-stdout.txt
+grep -f "${TEST_DIR}/expected.txt" actual-stderr.txt
+
+# Run import sanity tests which require modifications to the source directory.
+
vendor_dir="$(python -c 'import pathlib, ansible._vendor; print(pathlib.Path(ansible._vendor.__file__).parent)')"
cleanup() {