Skip to content

Commit

Permalink
separate yaml processing from running
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkzerwas committed Sep 24, 2024
1 parent d2685e7 commit f386637
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 49 deletions.
54 changes: 54 additions & 0 deletions test/cmake-check-setup.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
49 changes: 0 additions & 49 deletions test/cmake-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit f386637

Please sign in to comment.