#!/bin/sh
set -e

# Run from a copy, so that bleachbit/ in the source tree does not shadow
# the installed package.
cp -r tests setup.cfg po cleaners "$AUTOPKGTEST_TMP"
cd "$AUTOPKGTEST_TMP"

# The excluded tests need the source tree, the Windows and macOS modules
# that are not installed, or something a test bed may lack (see d/rules),
# or they misbehave as root: they expect permission errors, need mount or
# chattr +i, or wait for a click on a dialog. The suite takes about a
# minute: the timeout only stops a test that hangs on a dialog like that.
PYTHONPATH=/usr/share xvfb-run -a timeout 30m python3 -m pytest -p no:cacheprovider tests \
	--ignore=tests/TestMac.py \
	--ignore=tests/TestMakefile.py \
	--ignore=tests/TestNsisUtilities.py \
	--ignore=tests/TestWinapp.py \
	--ignore=tests/TestWindows.py \
	--deselect=tests/TestCLI.py::CLITestCase::test_debug_log \
	--deselect=tests/TestCLI.py::CLITestCase::test_encoding \
	--deselect=tests/TestCLI.py::CLITestCase::test_invalid_locale \
	--deselect=tests/TestCLI.py::CLITestCase::test_launcher_prefix_share \
	--deselect=tests/TestCLI.py::CLITestCase::test_preview \
	--deselect=tests/TestCLI.py::CLITestCase::test_return_text \
	--deselect=tests/TestCLI.py::CLITestCase::test_shred \
	--deselect=tests/TestCLI.py::CLITestCase::test_sysinfo \
	--deselect=tests/TestCleanerML.py::CleanerMLTestCase::test_default_vars_windows_system \
	--deselect=tests/TestCookie.py::CookieTestCase::test_load_keep_list_chmod \
	--deselect=tests/TestExternalCommand.py::ExternalCommandTestCase::test_windows_explorer_context_menu_natural \
	--deselect=tests/TestFileUtilities.py::FileUtilitiesTestCase::test_delete_mount_point \
	--deselect=tests/TestFileUtilities.py::FileUtilitiesTestCase::test_free_space \
	--deselect=tests/TestFileUtilities.py::FileUtilitiesTestCase::test_same_partition \
	--deselect=tests/TestGuiBasic.py::GuiBasicTestCase::test_open_url_accepts_http_https \
	--deselect=tests/TestGuiStartup.py::GuiStartupTestCase::test_config_permission_issue_missing_dir_non_writeable_parent \
	--deselect=tests/TestGuiStartup.py::GuiStartupTestCase::test_config_permission_issue_non_writeable_options_dir \
	--deselect=tests/TestGuiStartup.py::GuiStartupTestCase::test_is_config_writable \
	--deselect=tests/TestInit.py::InitTestCase::test_expanduser \
	--deselect=tests/TestLanguage.py::LanguageTestCase::test_get_text_all \
	--deselect=tests/TestMemory.py::MemoryTestCase::test_get_proc_swaps \
	--deselect=tests/TestNetwork.py::NetworkTestCase::test_get_ip_for_url \
	--deselect=tests/TestProcess.py::ProcessTestCase::test_enumerate_ps_aux \
	--deselect=tests/TestSystemInformation.py::SystemInformationTestCase::test_get_system_information_mac_version_name \
	--deselect=tests/TestSystemInformation.py::SystemInformationTestCase::test_get_system_information_mac_version_unknown_codename
