4
4
from pathlib import Path
5
5
import pytest
6
6
import subprocess
7
+ import os
7
8
8
9
10
+ IN_CI = len (os .getenv ("CI" , "" )) > 0
11
+
9
12
@pytest .fixture (scope = "session" )
10
13
def export_test_cases_dir (request ):
11
14
r = request .config .getoption ("--export-test-cases" )
@@ -32,9 +35,12 @@ def validate(request, export_test_cases_dir: Path):
32
35
# Check if the validator is installed
33
36
validator = get_validator ()
34
37
if validator is None :
35
- pytest .fail ("Run `cargo build -p release` to install the validator" )
36
- else :
37
- pytest .skip ("Skipping validation tests as requested" )
38
+ if IN_CI :
39
+ pytest .fail ("Validator not installed" )
40
+ else :
41
+ pytest .skip (
42
+ "Skipping validation: Run `cargo build` to install the validator"
43
+ )
38
44
39
45
def validate_json (hugr : str ):
40
46
# Executes `cargo run -p validator -- validate -`
@@ -74,15 +80,20 @@ def f(hugr: Package, expected: int, fn_name: str = "main"):
74
80
import execute_llvm
75
81
76
82
if not hasattr (execute_llvm , "run_int_function" ):
77
- pytest .skip ("Skipping llvm execution" )
83
+ if IN_CI :
84
+ pytest .fail ("run_int_function not available in CI" )
85
+ else :
86
+ pytest .skip ("Skipping llvm execution" )
78
87
79
88
hugr_json : str = hugr .modules [0 ].to_json ()
80
89
res = execute_llvm .run_int_function (hugr_json , fn_name )
81
90
if res != expected :
82
91
raise LLVMException (
83
92
f"Expected value ({ expected } ) doesn't match actual value ({ res } )"
84
93
)
85
- except ImportError :
86
- pytest .skip ("Skipping llvm execution" )
87
-
94
+ except ImportError as e :
95
+ if IN_CI :
96
+ pytest .fail (f"run_int_fn failed in CI: { e } " )
97
+ else :
98
+ pytest .skip ("Skipping llvm execution" )
88
99
return f
0 commit comments