From f386637c79252fc1696fc8b1c8dac35cd117b441 Mon Sep 17 00:00:00 2001 From: Dirk Zerwas Date: Tue, 24 Sep 2024 11:44:11 +0200 Subject: [PATCH] separate yaml processing from running --- test/cmake-check-setup.sh | 54 +++++++++++++++++++++++++++++++++++++++ test/cmake-check.sh | 49 ----------------------------------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/test/cmake-check-setup.sh b/test/cmake-check-setup.sh index 2de1ba6..5e54d29 100755 --- a/test/cmake-check-setup.sh +++ b/test/cmake-check-setup.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -e +shopt -s expand_aliases +source ../setup.sh CWD=${PWD} # only create the directory if it does not exist yet @@ -20,4 +22,56 @@ for yamlFileWithPath in "$EXAMPLEDIR"/FermionProduction.*yaml; do fi done +cd ci-setups + +# STEP 1: check the input + +for yamlFile in *.yaml; do + processYAML "$yamlFile" +done + +function processYAML() { + local yamlFile="$1" + local filename="${yamlFile%.yaml}" + + mkdir -p "test-$filename" + cd "test-$filename" + echo "Processing file: $yamlFile" + k4gen -f "../$yamlFile" --nevts 100 + checkOutputs + cd .. +} + +function checkOutputs() { + # for generator in */*; do + # if [[ -d "$generator" ]] || continue + echo "Checking $generator" + for outFile in "$PWD/$generator"/*/*; do + [[ -f "$outFile" ]] || continue + local fullpath="$(dirname "$outFile")" + local procname="$(basename "$fullpath")" + checkFile "$generator" "$procname" "$(basename "$outFile")" + # done + done +} + +function checkFile() { + local generator="$1" + local refgenerator="$(basename "$generator")" + local procname="$2" + local outFile="$3" + if [[ -e "$REFDIR/$refgenerator/$procname/$outFile" ]]; then + if diff "$REFDIR/$refgenerator/$procname/$outFile" "$PWD/$generator/$procname/$outFile" &> /dev/null; then + echo "Process " $procname : "Files are identical for file" $outFile + else + echo "Process " $procname "Files are different for file" $outFile + diff "$REFDIR/$refgenerator/$procname/$outFile" "$PWD/$generator/$procname/$outFile" + exit 1 + fi + else + echo "Did not find $outFile. Not checking!" + fi +} + + exit 0 diff --git a/test/cmake-check.sh b/test/cmake-check.sh index ed3e76f..ea56b2f 100755 --- a/test/cmake-check.sh +++ b/test/cmake-check.sh @@ -44,55 +44,6 @@ REFDIR="${PWD}/ref-results" EXAMPLEDIR="${PWD}/../examples" cd ci-setups -function checkFile() { - local generator="$1" - local refgenerator="$(basename "$generator")" - local procname="$2" - local outFile="$3" - if [[ -e "$REFDIR/$refgenerator/$procname/$outFile" ]]; then - if diff "$REFDIR/$refgenerator/$procname/$outFile" "$PWD/$generator/$procname/$outFile" &> /dev/null; then - echo "Process " $procname : "Files are identical for file" $outFile - else - echo "Process " $procname "Files are different for file" $outFile - diff "$REFDIR/$refgenerator/$procname/$outFile" "$PWD/$generator/$procname/$outFile" - exit 1 - fi - else - echo "Did not find $outFile. Not checking!" - fi -} - -function checkOutputs() { - # for generator in */*; do - # if [[ -d "$generator" ]] || continue - echo "Checking $generator" - for outFile in "$PWD/$generator"/*/*; do - [[ -f "$outFile" ]] || continue - local fullpath="$(dirname "$outFile")" - local procname="$(basename "$fullpath")" - checkFile "$generator" "$procname" "$(basename "$outFile")" - # done - done -} - -function processYAML() { - local yamlFile="$1" - local filename="${yamlFile%.yaml}" - - mkdir -p "test-$filename" - cd "test-$filename" - echo "Processing file: $yamlFile" - k4gen -f "../$yamlFile" --nevts 100 - checkOutputs - cd .. -} - -# STEP 1: check the input - -for yamlFile in *.yaml; do - processYAML "$yamlFile" -done - # STEP 2: run the generators function processRun() {