#!/bin/sh

# Hack to ensure git is manually marked
# Many tests will attempt to mark it as manually installed, and will
# fail when missing root privileges
/usr/bin/apt-mark manual git

# Tell git not to warn on weird permissions
git config --global --add safe.directory '*'

# So locale manually in the config files. ansible expects those for
# ansible-test.
echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
echo 'LANG=en_US.UTF-8' > /etc/default/locale

echo 'dpkg-reconfigure locales'
dpkg-reconfigure --frontend=noninteractive locales

# exclude all tests requiring a running ssh server
# grep 'needs/ssh' test/integration/targets/*/aliases

# ansible-test requires virtualenv and installs python libs from remote
# violating "Non-Main II" from https://ftp-master.debian.org/REJECT-FAQ.html

# ansible-test-docker requires pwsh to test .ps1 scripts, which doesn't
# exist in Debian.

# apt_key: requires keyserver.ubuntu.com to be reachable, which times out
# quite often.

# infra:
# ERROR: Invalid "needs/file/*" aliases:
# hacking/test-module.py

# remote_tmp: Will often show false positive on: "Test tempdir is removed"
# Needs upstream fixing.

# template_jinja2_latest: Downloads/runs latest jinja2, violating
# "Non-Main II" from https://ftp-master.debian.org/REJECT-FAQ.html

# var_templating must be run as non-root; exclude for now

/usr/bin/ansible-test integration \
  --python-interpreter /usr/bin/python3 \
  --python 3.9 \
  --exclude ansible-galaxy \
  --exclude ansible-test \
  --exclude ansible-test-docker \
  --exclude apt \
  --exclude apt_key \
  --exclude cli \
  --exclude collections_runtime_pythonpath \
  --exclude connection_paramiko_ssh \
  --exclude connection_ssh \
  --exclude copy \
  --exclude delegate_to \
  --exclude expect \
  --exclude get_url \
  --exclude incidental_inventory_docker_swarm \
  --exclude incidental_mongodb_parameter \
  --exclude incidental_postgresql_user \
  --exclude incidental_xml \
  --exclude infra \
  --exclude module_tracebacks \
  --exclude pip \
  --exclude remote_tmp \
  --exclude subversion \
  --exclude template_jinja2_latest \
  --exclude var_templating \
  --allow-destructive \
  --local \
  --retry-on-error \
  --continue-on-error
