Skip to content

Commit 45d1de2

Browse files
authored
Merge pull request #3307 from stan-dev/ci/distribution-tests-tweaks
Try to improve error handling of parallel distribution tests
2 parents ac8c21a + a587b5c commit 45d1de2

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

Jenkinsfile

100644100755
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,12 @@ pipeline {
487487
steps {
488488
script {
489489
retry(3) { checkout scm }
490+
491+
if (params.withRowVector || isBranch('develop') || isBranch('master')) {
492+
sh "echo CXXFLAGS+=-DSTAN_TEST_ROW_VECTORS >> make/local"
493+
sh "echo CXXFLAGS+=-DSTAN_PROB_TEST_ALL >> make/local"
494+
}
495+
490496
if (params.runAllDistributions || isBranch('develop') || isBranch('master')) {
491497
changedDistributionTests = sh(script:"python3 test/prob/getDependencies.py --pretend-all", returnStdout:true).trim().readLines()
492498
} else {
@@ -511,12 +517,17 @@ pipeline {
511517
steps {
512518
script {
513519
def tests = [:]
514-
for (f in changedDistributionTests.collate(24)) {
520+
521+
def executors = 10
522+
def tests_per_executor = Math.ceil((changedDistributionTests.size() / executors).doubleValue()).toInteger()
523+
def idx = 0
524+
for (f in changedDistributionTests.collate(tests_per_executor)) {
525+
idx = idx + 1
515526
def names = f.join(" ")
516-
tests["Distribution Tests: ${names}"] = { node ("linux && docker && 8core") {
527+
tests["Distribution Tests: ${idx} / ${executors}"] = { node ("linux && docker && 8core") {
517528
deleteDir()
518529
docker.image('stanorg/ci:gpu-cpp17').inside {
519-
catchError {
530+
catchError(buildResult: "FAILURE", stageResult: "FAILURE") {
520531
unstash 'MathSetup'
521532
sh """
522533
echo CXX=${CLANG_CXX} > make/local

test/prob/getDependencies.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
import subprocess
1111
from pathlib import Path
12-
12+
import glob
1313

1414
def get_dependencies(file: Path) -> Set[str]:
1515
file_dot_d = file.with_suffix(".d")
@@ -36,6 +36,11 @@ def get_changed() -> Set[str]:
3636
return set(changed_files)
3737

3838

39+
def add_tests_from_hpp(tests_to_run, test):
40+
pattern = str(test).replace("_test.hpp", "_0*_test.cpp")
41+
tests = glob.glob(pattern)
42+
tests_to_run.extend(tests)
43+
3944
if __name__ == "__main__":
4045
if Path("makefile") not in Path(".").iterdir():
4146
raise ValueError("getDependencies must be ran from the top-level repository")
@@ -47,12 +52,16 @@ def get_changed() -> Set[str]:
4752

4853
distribution_tests = Path("test", "prob")
4954

55+
subprocess.run(["make", "generate-tests"], stdout=subprocess.DEVNULL)
56+
5057
for dist in distribution_tests.iterdir():
5158
if not dist.is_dir():
5259
continue
60+
print(f"Considering {dist}.", file=sys.stderr)
5361
for test in dist.iterdir():
62+
if test.suffix != ".hpp": continue
5463
if pretend:
55-
tests_to_run.append(str(test).replace("_test.hpp", "_0*_test.cpp"))
64+
add_tests_from_hpp(tests_to_run, test)
5665
else:
5766
deps = get_dependencies(test)
5867
intersection = changed & deps
@@ -61,7 +70,6 @@ def get_changed() -> Set[str]:
6170
f"{test} has {len(intersection)} changed dependencies out of {len(deps)} files #included.",
6271
file=sys.stderr,
6372
)
73+
add_tests_from_hpp(tests_to_run, test)
6474

65-
tests_to_run.append(str(test).replace("_test.hpp", "_0*_test.cpp"))
66-
67-
print("\n".join(tests_to_run))
75+
print("\n".join(set(tests_to_run)))

0 commit comments

Comments
 (0)