Created
April 27, 2023 16:23
-
-
Save DigitalBrains1/adda2182bb0dd9dc86af3ce2f148ceb4 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import os | |
import subprocess | |
import tempfile | |
def run(args, cwd): | |
return subprocess.run(args, cwd=cwd, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) | |
def comb_to_string(comb): | |
ghc, hashable, primitive = comb | |
return f"ghc-{ghc}, hashable-{hashable}, primitive-{primitive}" | |
def combs(): | |
ghc_versions = ["9.4.5", "9.2.7", "9.0.2", "8.10.7", "8.8.4", "8.6.5"] | |
hashable_versions = ["1.4.2.0", "1.4.1.0", "1.4.0.2"] | |
primitive_versions = ["0.8.0.0", "0.7.4.0"] | |
for ghc in ghc_versions: | |
for hashable in hashable_versions: | |
if ghc == "9.4.5" and hashable == "1.4.0.2": | |
# Unsupported version | |
continue | |
for primtive in primitive_versions: | |
yield (ghc, hashable, primtive) | |
def try_comb(comb): | |
ghc, hashable, primitive = comb | |
with tempfile.TemporaryDirectory() as tmpdir: | |
project_root = os.path.join(tmpdir, "test-hashable-primitive") | |
run( | |
[ | |
"git", "clone", | |
"https://github.com/DigitalBrains1/test-hashable-primitive.git", | |
"-b", "current-situation", "--depth", "1" | |
], tmpdir | |
) | |
try: | |
run( | |
[ "cabal", "build", "all" | |
, f"--with-compiler", f"ghc-{ghc}" | |
, f"--constraint=hashable=={hashable}" | |
, f"--constraint=primitive=={primitive}" | |
], project_root) | |
except subprocess.CalledProcessError as e: | |
return (True, comb, e.stdout) | |
return (False, comb, "") | |
if __name__ == '__main__': | |
from multiprocessing import Pool | |
with Pool(6) as p: | |
for result in p.imap_unordered(try_comb, combs()): | |
(failed, comb, output) = result | |
if failed: | |
print(f"FAIL: {comb_to_string(comb)}") | |
with open(f"/tmp/thp-fails/{comb_to_string(comb)}.log", "w") as fp: | |
fp.write(output) | |
else: | |
print(f"OK: {comb_to_string(comb)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment