From cf88b0a63b2e34b64cb87313ca1f371f848b8ee1 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 10 Aug 2023 16:27:49 +0100 Subject: [PATCH] add poetry test scripts for each kind --- pyproject.toml | 5 ++++- scripts.py | 19 ++++++++++++++++++- tests/__init__.py | 7 +++++-- tests/pre-commit.ps1 | 6 +++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cfdd9a8..fbc4031 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,10 @@ levels = "scripts:ex_levels" midi = "scripts:ex_midi" obs = "scripts:ex_obs" observer = "scripts:ex_observer" -test = "scripts:test" +basic = "scripts:test_basic" +banana = "scripts:test_banana" +potato = "scripts:test_potato" +all = "scripts:test_all" [tool.tox] legacy_tox_ini = """ diff --git a/scripts.py b/scripts.py index 829d0f6..4577897 100644 --- a/scripts.py +++ b/scripts.py @@ -1,3 +1,4 @@ +import os import subprocess import sys from pathlib import Path @@ -38,5 +39,21 @@ def ex_observer(): subprocess.run([sys.executable, str(scriptpath)]) -def test(): +def test_basic(): + os.environ["KIND"] = "basic" subprocess.run(["tox"]) + + +def test_banana(): + os.environ["KIND"] = "banana" + subprocess.run(["tox"]) + + +def test_potato(): + os.environ["KIND"] = "potato" + subprocess.run(["tox"]) + + +def test_all(): + steps = [test_basic, test_banana, test_potato] + [step() for step in steps] diff --git a/tests/__init__.py b/tests/__init__.py index 19bb563..64990aa 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,4 @@ +import os import random import sys from dataclasses import dataclass @@ -30,8 +31,10 @@ class Data: return (2 * self.phys_in) + (8 * self.virt_in) -# let's keep things random -KIND_ID = random.choice(tuple(kind_id.name.lower() for kind_id in KindId)) +# get KIND_ID from env var, otherwise set to random +KIND_ID = os.environ.get( + "KIND", random.choice(tuple(kind_id.name.lower() for kind_id in KindId)) +) vm = voicemeeterlib.api(KIND_ID) kind = kindmap(KIND_ID) diff --git a/tests/pre-commit.ps1 b/tests/pre-commit.ps1 index ee004ea..f637563 100644 --- a/tests/pre-commit.ps1 +++ b/tests/pre-commit.ps1 @@ -25,7 +25,11 @@ Function Get-TimeStamp { if ($MyInvocation.InvocationName -ne ".") { Invoke-Expression ".\.venv\Scripts\Activate.ps1" - RunTests + @("potato") | ForEach-Object { + $env:KIND = $_ + RunTests + } + Invoke-Expression "deactivate" }