Debian Codegraph @

test/integration/targets/ansible-test-sanity-shebang/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eu
4
5 # Create test scenarios at runtime that do not pass sanity tests.
6 # This avoids the need to create ignore entries for the tests.
7
8 (
9 cd ansible_collections/ns/col/plugins/modules
10
11 touch no-shebang-executable.py && chmod +x no-shebang-executable.py # file without shebang should not be executable
12 python -c "open('utf-32-be-bom.py', 'wb').write(b'\x00\x00\xFE\xFF')" # file starts with a UTF-32 (BE) byte order mark
13 python -c "open('utf-32-le-bom.py', 'wb').write(b'\xFF\xFE\x00\x00')" # file starts with a UTF-32 (LE) byte order mark
14 python -c "open('utf-16-be-bom.py', 'wb').write(b'\xFE\xFF')" # file starts with a UTF-16 (BE) byte order mark
15 python -c "open('utf-16-le-bom.py', 'wb').write(b'\xFF\xFE')" # file starts with a UTF-16 (LE) byte order mark
16 python -c "open('utf-8-bom.py', 'wb').write(b'\xEF\xBB\xBF')" # file starts with a UTF-8 byte order mark
17 echo '#!/usr/bin/python' > python-executable.py && chmod +x python-executable.py # module should not be executable
18 echo '#!invalid' > python-wrong-shebang.py # expected module shebang "b'#!/usr/bin/python'" but found: b'#!invalid'
19 )
20
21 (
22 cd ansible_collections/ns/col/scripts
23
24 echo '#!/usr/bin/custom' > unexpected-shebang # unexpected non-module shebang: b'#!/usr/bin/custom'
25
26 echo '#!/usr/bin/make -f' > Makefile && chmod +x Makefile # pass
27 echo '#!/bin/bash -eu' > bash_eu.sh && chmod +x bash_eu.sh # pass
28 echo '#!/bin/bash -eux' > bash_eux.sh && chmod +x bash_eux.sh # pass
29 echo '#!/usr/bin/env fish' > env_fish.fish && chmod +x env_fish.fish # pass
30 echo '#!/usr/bin/env pwsh' > env_pwsh.ps1 && chmod +x env_pwsh.ps1 # pass
31 )
32
33 mkdir ansible_collections/ns/col/examples
34
35 (
36 cd ansible_collections/ns/col/examples
37
38 echo '#!/usr/bin/custom' > unexpected-shebang # pass
39 )
40
41 source ../collection/setup.sh
42
43 set -x
44
45 ansible-test sanity --test shebang --color --lint --failure-ok "${@}" > actual.txt
46
47 diff -u "${TEST_DIR}/expected.txt" actual.txt