From 9b750fe100a80a8db0b406ad470e57f22ce69a57 Mon Sep 17 00:00:00 2001 From: donny-wong <141858744+donny-wong@users.noreply.github.com> Date: Fri, 31 May 2024 20:44:06 -0400 Subject: [PATCH] haskell tester: make stack resolver version a user setting (#526) --- Changelog.md | 1 + .../testers/haskell/haskell_tester.py | 4 ++-- .../testers/haskell/settings_schema.json | 17 +++++++++++++++++ server/autotest_server/testers/haskell/setup.py | 12 ++++++++---- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 7248b0be..366f3570 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented here. ## [unreleased] - Add tidyverse as a default R tester package (#512) +- For the Haskell tester, make stack resolver a test setting (#526) ## [v2.4.3] - Omit skipped test cases in Python tester (#522) diff --git a/server/autotest_server/testers/haskell/haskell_tester.py b/server/autotest_server/testers/haskell/haskell_tester.py index 754e3c25..c0ba5f4c 100644 --- a/server/autotest_server/testers/haskell/haskell_tester.py +++ b/server/autotest_server/testers/haskell/haskell_tester.py @@ -7,8 +7,6 @@ from ..tester import Tester, Test, TestError from ..specs import TestSpecs -STACK_OPTIONS = ["--resolver=lts-16.17", "--system-ghc", "--allow-different-user"] - class HaskellTest(Test): def __init__( @@ -101,6 +99,8 @@ def run_haskell_tests(self) -> Dict[str, List[Dict[str, Union[int, str]]]]: Tests are run by first discovering all tests from a specific module (using tasty-discover) and then running all the discovered tests and parsing the results from a csv file. """ + resolver = self.specs["env_data", "resolver_version"] + STACK_OPTIONS = [f"--resolver={resolver}", "--system-ghc", "--allow-different-user"] results = {} this_dir = os.getcwd() haskell_lib = os.path.join(os.path.dirname(os.path.realpath(__file__)), "lib") diff --git a/server/autotest_server/testers/haskell/settings_schema.json b/server/autotest_server/testers/haskell/settings_schema.json index f034c97c..5fd49f3d 100644 --- a/server/autotest_server/testers/haskell/settings_schema.json +++ b/server/autotest_server/testers/haskell/settings_schema.json @@ -1,5 +1,8 @@ { "type": "object", + "required": [ + "env_data" + ], "properties": { "tester_type": { "type": "string", @@ -7,6 +10,20 @@ "haskell" ] }, + "env_data": { + "title": "Haskell environment", + "type": "object", + "required": [ + "resolver_version" + ], + "properties": { + "resolver_version": { + "title": "Resolver version", + "type": "string", + "default": null + } + } + }, "test_data": { "title": "Test Groups", "type": "array", diff --git a/server/autotest_server/testers/haskell/setup.py b/server/autotest_server/testers/haskell/setup.py index 43f8090c..f1b3efa0 100644 --- a/server/autotest_server/testers/haskell/setup.py +++ b/server/autotest_server/testers/haskell/setup.py @@ -2,12 +2,13 @@ import json import subprocess - HASKELL_TEST_DEPS = ["tasty-discover", "tasty-quickcheck"] +STACK_RESOLVER = "lts-16.17" def create_environment(_settings, _env_dir, default_env_dir): - resolver = "lts-16.17" + env_data = _settings.get("env_data", {}) + resolver = env_data.get("resolver_version", STACK_RESOLVER) cmd = ["stack", "build", "--resolver", resolver, "--system-ghc", *HASKELL_TEST_DEPS] subprocess.run(cmd, check=True) @@ -16,7 +17,7 @@ def create_environment(_settings, _env_dir, default_env_dir): def install(): subprocess.run(os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.system"), check=True) - resolver = "lts-16.17" + resolver = STACK_RESOLVER cmd = ["stack", "build", "--resolver", resolver, "--system-ghc", *HASKELL_TEST_DEPS] subprocess.run(cmd, check=True) subprocess.run( @@ -26,4 +27,7 @@ def install(): def settings(): with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "settings_schema.json")) as f: - return json.load(f) + settings_ = json.load(f) + resolver_versions = settings_["properties"]["env_data"]["properties"]["resolver_version"] + resolver_versions["default"] = STACK_RESOLVER + return settings_