-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Timo Reichl <thetredev@gmail.com>
- Loading branch information
Showing
12 changed files
with
328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
bin | ||
html | ||
**/.pytest_cache | ||
**/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# note: tests will run with 'latest' version of xdeb for now | ||
# because tests/test_xdeb.py installs 'latest' last | ||
|
||
mkdir -p html | ||
PYTEST_TEST_REPORT_ARGS="--html=html/test-report.html --self-contained-html" | ||
|
||
if [ "${1}" = "html" ]; then | ||
pytest ${PYTEST_TEST_REPORT_ARGS} | ||
else | ||
pytest | ||
fi |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
from pathlib import Path | ||
|
||
|
||
DEB_NONEXISTENT_PACKAGE = "DEFINITELY-NON-EXISTENT-PACKAGE" | ||
|
||
|
||
XDEB_BINARY_PATH = Path("/usr/local/bin/xdeb") | ||
XDEB_RELEASES = ( | ||
"1.0", | ||
"1.1", | ||
"1.2", | ||
"1.3" | ||
) | ||
|
||
XDEB_INSTALL_BINARY_PATH = Path(__file__).parent.parent.joinpath("bin", "xdeb-install-linux-x86_64") | ||
|
||
XDEB_INSTALL_PROVIDERS = ( | ||
"debian.org", | ||
"linuxmint.com", | ||
"ubuntu.com", | ||
"microsoft.com", | ||
"google.com", | ||
) | ||
|
||
XDEB_INSTALL_HAVE_PACKAGE = { | ||
"speedcrunch": { | ||
"debian.org": { | ||
"any": True, | ||
"distributions": { | ||
"bookworm": True, | ||
"bookworm-backports": False, | ||
"bullseye": True, | ||
"bullseye-backports": False, | ||
"buster": True, | ||
"buster-backports": False, | ||
"sid": True, | ||
"testing": True, | ||
"testing-backports": False | ||
}, | ||
}, | ||
"linuxmint.com": { | ||
"any": False | ||
}, | ||
"ubuntu.com": { | ||
"any": True, | ||
"distributions": { | ||
"bionic": True, | ||
"focal": True, | ||
"jammy": True | ||
} | ||
}, | ||
"microsoft.com": { | ||
"any": False | ||
}, | ||
"google.com": { | ||
"any": False | ||
}, | ||
}, | ||
"vscode": { | ||
"debian.org": { | ||
"any": False | ||
}, | ||
"linuxmint.com": { | ||
"any": False | ||
}, | ||
"ubuntu.com": { | ||
"any": False | ||
}, | ||
"microsoft.com": { | ||
"any": True, | ||
"distributions": { | ||
"current": True | ||
} | ||
}, | ||
"google.com": { | ||
"any": False | ||
} | ||
}, | ||
"google-chrome": { | ||
"debian.org": { | ||
"any": False | ||
}, | ||
"linuxmint.com": { | ||
"any": False | ||
}, | ||
"ubuntu.com": { | ||
"any": False | ||
}, | ||
"microsoft.com": { | ||
"any": False | ||
}, | ||
"google.com": { | ||
"any": True, | ||
"distributions": { | ||
"current": True | ||
} | ||
} | ||
}, | ||
"google-chrome-unstable": { | ||
"debian.org": { | ||
"any": False | ||
}, | ||
"linuxmint.com": { | ||
"any": False | ||
}, | ||
"ubuntu.com": { | ||
"any": False | ||
}, | ||
"microsoft.com": { | ||
"any": False | ||
}, | ||
"google.com": { | ||
"any": True, | ||
"distributions": { | ||
"current": True | ||
} | ||
} | ||
} | ||
} | ||
|
||
XDEB_INSTALL_PACKAGE_MAP = { | ||
"vscode": "code", | ||
"google-chrome": "google-chrome-stable" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import subprocess | ||
|
||
from . import constants | ||
|
||
|
||
def assert_xdeb_install_command(*args): | ||
subprocess.check_call([constants.XDEB_INSTALL_BINARY_PATH, *args]) | ||
|
||
|
||
def assert_command_assume_yes(returncode: int, *args): | ||
process = subprocess.run(*args, input="yes\n".encode(), stdout=subprocess.PIPE) | ||
assert process.returncode == returncode | ||
|
||
|
||
def assert_xdeb_install_xbps(returncode: int, *args): | ||
assert_command_assume_yes(returncode, [constants.XDEB_INSTALL_BINARY_PATH, *args]) | ||
|
||
if returncode == 0: | ||
package = args[-1] if args[-1] not in constants.XDEB_INSTALL_PACKAGE_MAP else constants.XDEB_INSTALL_PACKAGE_MAP[args[-1]] | ||
assert_command_assume_yes(0, ["sudo", "xbps-remove", package]) | ||
assert_command_assume_yes(0, ["sudo", "xbps-remove", "-Oo"]) | ||
|
||
|
||
def assert_xdeb_installation(version: str = None): | ||
# remove any previous xdeb binary | ||
subprocess.check_call(["sudo", "rm", "-rf", constants.XDEB_BINARY_PATH]) | ||
|
||
# install xdeb version | ||
args = ["xdeb"] | ||
|
||
if version is not None: | ||
args.append(version) | ||
|
||
assert_xdeb_install_command(*args) | ||
subprocess.check_call([constants.XDEB_BINARY_PATH, "-h"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
from . import helpers | ||
|
||
|
||
@pytest.mark.order(0) | ||
def test_version(): | ||
helpers.assert_xdeb_install_command("--version") | ||
|
||
|
||
@pytest.mark.order(1) | ||
def test_help(): | ||
helpers.assert_xdeb_install_command("--help") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
|
||
from . import constants | ||
from . import helpers | ||
|
||
|
||
@pytest.mark.order(10) | ||
def test_xdeb(): | ||
helpers.assert_xdeb_installation() | ||
|
||
for release in constants.XDEB_RELEASES: | ||
helpers.assert_xdeb_installation(release) | ||
|
||
helpers.assert_xdeb_installation("latest") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
from . import helpers | ||
|
||
|
||
@pytest.mark.order(20) | ||
def test_providers(): | ||
helpers.assert_xdeb_install_command("providers") | ||
|
||
|
||
@pytest.mark.order(21) | ||
def test_providers_details(): | ||
helpers.assert_xdeb_install_command("providers", "--details") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
from . import constants | ||
from . import helpers | ||
|
||
|
||
@pytest.mark.order(30) | ||
def test_sync(): | ||
helpers.assert_xdeb_install_command("sync") | ||
|
||
|
||
@pytest.mark.order(31) | ||
def test_sync_single(): | ||
for provider in constants.XDEB_INSTALL_PROVIDERS: | ||
helpers.assert_xdeb_install_command("sync", provider) | ||
|
||
|
||
@pytest.mark.order(32) | ||
def test_sync_each(): | ||
helpers.assert_xdeb_install_command("sync", *constants.XDEB_INSTALL_PROVIDERS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import subprocess | ||
import pytest | ||
|
||
from . import constants | ||
from . import helpers | ||
|
||
|
||
@pytest.mark.order(40) | ||
def test_search_nothing(): | ||
with pytest.raises(subprocess.CalledProcessError): | ||
helpers.assert_xdeb_install_command("search") | ||
|
||
|
||
@pytest.mark.order(41) | ||
def test_search_nonexistent(): | ||
with pytest.raises(subprocess.CalledProcessError): | ||
helpers.assert_xdeb_install_command("search", constants.DEB_NONEXISTENT_PACKAGE) | ||
|
||
|
||
@pytest.mark.order(42) | ||
def test_search_speedcrunch(): | ||
helpers.assert_xdeb_install_command("search", "speedcrunch") | ||
|
||
|
||
@pytest.mark.order(43) | ||
def test_search_packages(): | ||
for package, provider_data in constants.XDEB_INSTALL_HAVE_PACKAGE.items(): | ||
for provider, data in provider_data.items(): | ||
if not data["any"]: | ||
with pytest.raises(subprocess.CalledProcessError): | ||
helpers.assert_xdeb_install_command("search", "--provider", provider, package) | ||
continue | ||
|
||
helpers.assert_xdeb_install_command("search", "--provider", provider, package) | ||
|
||
for distribution, available in data["distributions"].items(): | ||
if not available: | ||
with pytest.raises(subprocess.CalledProcessError): | ||
helpers.assert_xdeb_install_command("search", "--provider", provider, "--distribution", distribution, package) | ||
continue | ||
|
||
helpers.assert_xdeb_install_command("search", "--provider", provider, "--distribution", distribution, package) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import pytest | ||
|
||
from . import constants | ||
from . import helpers | ||
|
||
|
||
@pytest.mark.order(51) | ||
def test_install_nothing(): | ||
helpers.assert_xdeb_install_xbps(1) | ||
|
||
|
||
@pytest.mark.order(52) | ||
def test_install_nonexistent(): | ||
helpers.assert_xdeb_install_xbps(1, constants.DEB_NONEXISTENT_PACKAGE) | ||
|
||
|
||
@pytest.mark.order(53) | ||
def test_install_speedcrunch(): | ||
helpers.assert_xdeb_install_xbps(0, "speedcrunch") | ||
|
||
|
||
@pytest.mark.order(54) | ||
def test_install_packages(): | ||
for package, provider_data in constants.XDEB_INSTALL_HAVE_PACKAGE.items(): | ||
for provider, data in provider_data.items(): | ||
if not data["any"]: | ||
helpers.assert_xdeb_install_xbps(1, "--provider", provider, package) | ||
continue | ||
|
||
helpers.assert_xdeb_install_xbps(0, "--provider", provider, package) | ||
|
||
for distribution, available in data["distributions"].items(): | ||
if not available: | ||
helpers.assert_xdeb_install_xbps(1, "--provider", provider, "--distribution", distribution, package) | ||
continue | ||
|
||
helpers.assert_xdeb_install_xbps(0, "--provider", provider, "--distribution", distribution, package) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
from . import helpers | ||
|
||
|
||
@pytest.mark.order(60) | ||
def test_clean(): | ||
helpers.assert_xdeb_install_command("clean") | ||
|
||
|
||
@pytest.mark.order(61) | ||
def test_clean_lists(): | ||
helpers.assert_xdeb_install_command("clean", "--lists") |