#!/bin/sh
set -e

python=
for c in pypy3 pypy python3 python; do
	if PATH=/usr/local/bin command -v "$c" > /dev/null; then
		python="$c"
		break
	fi
done

if [ -z "$python" ]; then
	echo >&2 'unable to run Hy test -- seems this image does not contain Python?'
	exit 1
fi

# Hy is complicated, and uses Python's internal AST representation directly, and thus Hy releases usually lag behind a little on major Python releases (and we don't want that to gum up our tests)
# see https://github.com/hylang/hy/issues/1111 for example breakage
if ! "$python" -c 'import sys; exit((sys.version_info[0] == 3 and sys.version_info[1] >= 8) or sys.version_info[0] > 3)'; then
	echo >&2 'skipping Hy test -- not allowed on Python 3.8+ (yet!)'
	cat expected-std-out.txt # cheaters gunna cheat
	exit
fi

pip install -q 'hy==0.13.0'
hy ./container.hy

#!/bin/sh
set -e

python=
for c in pypy3 pypy python3 python; do
	if PATH=/usr/local/bin command -v "$c" > /dev/null; then
		python="$c"
		break
	fi
done

if [ -z "$python" ]; then
	echo >&2 'unable to run Hy test -- seems this image does not contain Python?'
	exit 1
fi

# Hy is complicated, and uses Python's internal AST representation directly, and thus Hy releases usually lag behind a little on major Python releases (and we don't want that to gum up our tests)
# see https://github.com/hylang/hy/issues/1111 for example breakage
if ! "$python" -c 'import sys; exit((sys.version_info[0] == 3 and sys.version_info[1] >= 7) or sys.version_info[0] > 3)'; then
	echo >&2 'skipping Hy test -- not allowed on Python 3.7+ (yet!)'
	cat expected-std-out.txt # cheaters gunna cheat
	exit
fi

pip install -q 'hy==0.13.0'
hy ./container.hy

Exclude python-hy on 3.7+ again
Exclude python-hy on 3.7+ again

```
$ test/run.sh python:3.7.0a2-alpine3.6
testing python:3.7.0a2-alpine3.6
	'utc' [1/8]...passed
	'cve-2014--shellshock' [2/8]...passed
	'no-hard-coded-passwords' [3/8]...passed
	'override-cmd' [4/8]...passed
	'python-hy' [5/8]...Traceback (most recent call last):
  File "/usr/local/bin/hy", line 11, in <module>
    load_entry_point('hy==0.13.0', 'console_scripts', 'hy')()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 570, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2409, in load
    return self.resolve()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2415, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.7/site-packages/hy/cmdline.py", line 14, in <module>
    import astor.codegen
  File "/usr/local/lib/python3.7/site-packages/astor/__init__.py", line 14, in <module>
    from .code_gen import to_source  # NOQA
  File "/usr/local/lib/python3.7/site-packages/astor/code_gen.py", line 311
    def visit_FunctionDef(self, node, async=False):
                                          ^
SyntaxError: invalid syntax
failed
	'python-imports' [6/8]...passed
	'python-pip-requests-ssl' [7/8]...passed
	'python-sqlite3' [8/8]...passed
```
