Skip to content

Commit

Permalink
haskell tester: make stack resolver version a user setting (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
donny-wong authored Jun 1, 2024
1 parent 3d9a5e0 commit 9b750fe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions server/autotest_server/testers/haskell/haskell_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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")
Expand Down
17 changes: 17 additions & 0 deletions server/autotest_server/testers/haskell/settings_schema.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
{
"type": "object",
"required": [
"env_data"
],
"properties": {
"tester_type": {
"type": "string",
"enum": [
"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",
Expand Down
12 changes: 8 additions & 4 deletions server/autotest_server/testers/haskell/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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(
Expand All @@ -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_

0 comments on commit 9b750fe

Please sign in to comment.