summaryrefslogtreecommitdiffstats
path: root/lang/python/python-pexpect/test.sh
blob: 35cb3a3acd8aaafc5f2840563b013c24af1c5fb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

[ "$1" = "python3-pexpect" ] || exit 0

# current installed version from python metadata
installed_version="$(python3 -c 'import pexpect; print(pexpect.__version__)')"

# use expected version from package metadata/environment
expected_version="${PKG_VERSION}"

if [ "$installed_version" != "$expected_version" ]; then
    echo "Wrong version: $installed_version (expected $expected_version)"
    exit 1
fi

python3 - << 'EOF'
import pexpect

pattern = "pexpect-test"
child = pexpect.spawn('sh', ['-c', 'printf "%s\\n" "pexpect-test"'], encoding='utf-8')
child.expect_exact(pattern)
child.expect(pexpect.EOF)
child.close()
assert child.exitstatus == 0, f"child exited {child.exitstatus}"

print("python3-pexpect OK")
EOF