#!/bin/sh

# run upstream's integration tests

set -eux

. debian/tests/setup

## env
TESTS_DIR="${APTLY_SRC_DIR}/system"

## functions
disable_test() {
  local file=${1}.py
  local name=$2
  local reason=$3

  echo "${name}.skipTest = 'Debian autopkgtest: $reason'" >> ${TESTS_DIR}/${file}
}

## main
export USER=root # for t07/RootDirInaccessible

disable_test t01_version/version VersionTest "version"
disable_test t02_config/config CreateConfigTest "different conf"
disable_test t04_mirror/create CreateMirror31Test "public key not found"
disable_test t04_mirror/create CreateMirror35Test "flaky on s390"
disable_test t07_serve/serve Serve1Test "minor html diff"
disable_test t09_repo/edit EditRepo4Test "flaky on riscv64"
disable_test t10_task/run RunTask1Test "version"
disable_test t12_api/docs TaskAPITestSwaggerDocs "no recent swag"
disable_test t12_api/unix_socket UnixSocketAPITest "type mismatch"
disable_test t12_api/version VersionAPITest "type mismatch"
disable_test t14_graph/graph CreateGraphTest "no viewer"
disable_test t14_graph/graph CreateGraphOutputTest "no viewer"

# etcd fixture is entirely arch-specific
rm -fr ${TESTS_DIR}/t13_etcd

make -C $APTLY_SRC_DIR system-test
