Skip to content
Merged
36 changes: 14 additions & 22 deletions .github/workflows/mcstas-basictest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -464,35 +464,33 @@ jobs:
export MCSTAS_EXECUTABLE="mcstas"
export MCRUN_EXECUTABLE="mcrun"
export MCTEST_EXECUTABLE="mctest"
export PERMISSIVE=" "
export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/
# Check if any instr files were modified during last commit
cd src
export CHANGEDCOMPS=`git diff --name-only HEAD HEAD~1| grep \.comp\$ | grep mcstas-comps | xargs -n1 basename | sed s/\.comp//g | xargs echo`
export NUMCHANGEDCOMPS=`git diff --name-only HEAD HEAD~1|grep \.comp\$ | grep mcstas-comps | wc -l | xargs echo`
export COMPILIST=""
export RUNALL="NO"
if [ "$NUMCHANGEDCOMPS" != "0" ];
then
if [ "$NUMCHANGEDCOMPS" -lt "20" ];
then
for comp in $CHANGEDCOMPS;
do
echo Finding instruments matching component $comp
echo Finding tests including component $comp
NUMMATCH=`find mcstas-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | wc -l`
if [ "$NUMMATCH" -gt "0" ];
then
MATCH=`find mcstas-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export COMPILIST=`echo $COMPILIST $MATCH`
if [ "$RUNNER_OS" != "Windows" ]; then
mctest --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=${{ matrix.CC }}_CHANGES $PERMISSIVE
else
export COMPILIST=`echo $COMPILIST template_simple`
echo .\\install\\bin\\mctest --verbose --testdir run_${comp} --comp=${comp} --suffix=${{ matrix.CC }}_CHANGES --permissive >> ..\\changedinstr.bat
fi
done
else
export RUNALL="YES"
echo No matching tests found
fi
done
fi
export RUNALL="NO"
export CHANGEDINSTR=`git diff --name-only HEAD HEAD~1| grep \.instr\$ | grep mcstas-comps | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export CHANGEDINSTR=`echo $CHANGEDINSTR $COMPILIST | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export CHANGEDINSTR=`echo $CHANGEDINSTR | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export NUMCHANGEDINSTR=`git diff --name-only HEAD HEAD~1|grep \.instr\$ | grep mcstas-comps | wc -l | xargs echo`
echo ----
echo $NUMCHANGEDCOMPS components and $NUMCHANGEDINSTR instruments were changed, resulting in this list:
Expand All @@ -503,24 +501,20 @@ jobs:
then
export RUNALL="YES"
fi
export PERMISSIVE=" "
if [ "$NUMCHANGEDINSTR" != "0" ] || [ "$NUMCHANGEDCOMPS" != "0" ];
if [ "$NUMCHANGEDINSTR" != "0" ];
then
if [ "$RUNALL" == "NO" ];
then
export SCOPE="--instr=$CHANGEDINSTR"
else
export SCOPE=" "
fi
mkdir run_mctest && cd run_mctest
if [ "$RUNNER_OS" != "Windows" ]; then
mkdir run_mctest && cd run_mctest
if [ "$RUNNER_OS" == macOS ]; then
export PERMISSIVE="--permissive"
fi
../install_mcstas/bin/${MCTEST_EXECUTABLE} --testdir $PWD $SCOPE --suffix=${{ matrix.CC }}_CHANGES $PERMISSIVE
mctest --mpi=2 --testdir $PWD $SCOPE --suffix=${{ matrix.CC }}_CHANGES $PERMISSIVE
mcviewtest --nobrowse $PWD
else
echo ..\\install\\bin\\mctest --verbose --testdir=. $SCOPE --suffix=${{ matrix.CC }}_CHANGES --permissive > changedinstr.bat
echo .\\install\\bin\\mctest --verbose --testdir=run_mctest $SCOPE --suffix=${{ matrix.CC }}_CHANGES --permissive >> ..\\changedinstr.bat
fi
fi

Expand All @@ -532,9 +526,7 @@ jobs:
shell: cmd
run: |
if exist changedinstr.bat (
mkdir run_mctest
cd run_mctest
call ..\changedinstr.bat
call .\changedinstr.bat
)

# Start of Windows tests
Expand Down
25 changes: 11 additions & 14 deletions .github/workflows/mcstas-conda-basictest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,35 +218,33 @@ jobs:
export MCSTAS_EXECUTABLE="mcstas"
export MCRUN_EXECUTABLE="mcrun"
export MCTEST_EXECUTABLE="mctest"
export PERMISSIVE=" "
export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/
# Check if any instr files were modified during last commit
cd src
export CHANGEDCOMPS=`git diff --name-only HEAD HEAD~1| grep \.comp\$ | grep mcstas-comps | xargs -n1 basename | sed s/\.comp//g | xargs echo`
export NUMCHANGEDCOMPS=`git diff --name-only HEAD HEAD~1|grep \.comp\$ | grep mcstas-comps | wc -l | xargs echo`
export COMPILIST=""
export RUNALL="NO"
if [ "$NUMCHANGEDCOMPS" != "0" ];
then
if [ "$NUMCHANGEDCOMPS" -lt "20" ];
then
for comp in $CHANGEDCOMPS;
do
echo Finding instruments matching component $comp
echo Finding tests including component $comp
NUMMATCH=`find mcstas-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | wc -l`
if [ "$NUMMATCH" -gt "0" ];
then
MATCH=`find mcstas-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export COMPILIST=`echo $COMPILIST $MATCH`
if [ "$RUNNER_OS" != "Windows" ]; then
mctest --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES $PERMISSIVE
else
mctest.bat --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES $PERMISSIVE
fi
else
export COMPILIST=`echo $COMPILIST template_simple`
echo No matching tests found
fi
done
else
export RUNALL="YES"
fi
fi
export RUNALL="NO"
export CHANGEDINSTR=`git diff --name-only HEAD HEAD~1| grep \.instr\$ | grep mcstas-comps | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export CHANGEDINSTR=`echo $CHANGEDINSTR $COMPILIST | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export CHANGEDINSTR=`echo $CHANGEDINSTR | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export NUMCHANGEDINSTR=`git diff --name-only HEAD HEAD~1|grep \.instr\$ | grep mcstas-comps | wc -l | xargs echo`
echo ----
echo $NUMCHANGEDCOMPS components and $NUMCHANGEDINSTR instruments were changed, resulting in this list:
Expand All @@ -257,8 +255,7 @@ jobs:
then
export RUNALL="YES"
fi
export PERMISSIVE=" "
if [ "$NUMCHANGEDINSTR" != "0" ] || [ "$NUMCHANGEDCOMPS" != "0" ];
if [ "$NUMCHANGEDINSTR" != "0" ];
then
if [ "$RUNALL" == "NO" ];
then
Expand Down
36 changes: 14 additions & 22 deletions .github/workflows/mcxtrace-basictest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,35 +397,33 @@ jobs:
export MCXTRACE_EXECUTABLE="mcxtrace"
export MXRUN_EXECUTABLE="mxrun"
export MXTEST_EXECUTABLE="mxtest"
export PERMISSIVE=" "
export PATH=${PATH}:${PWD}/install_mcxtrace/bin/:${PWD}/install_mcxtrace/mcxtrace/3.99.99/bin/
# Check if any instr files were modified during last commit
cd src
export CHANGEDCOMPS=`git diff --name-only HEAD HEAD~1| grep \.comp\$ | grep mcxtrace-comps | xargs -n1 basename | sed s/\.comp//g | xargs echo`
export NUMCHANGEDCOMPS=`git diff --name-only HEAD HEAD~1|grep \.comp\$ | grep mcxtrace-comps | wc -l | xargs echo`
export COMPILIST=""
export RUNALL="NO"
if [ "$NUMCHANGEDCOMPS" != "0" ];
then
if [ "$NUMCHANGEDCOMPS" -lt "20" ];
then
for comp in $CHANGEDCOMPS;
do
echo Finding instruments matching component $comp
echo Finding tests including component $comp
NUMMATCH=`find mcxtrace-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | wc -l`
if [ "$NUMMATCH" -gt "0" ];
then
MATCH=`find mcxtrace-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export COMPILIST=`echo $COMPILIST $MATCH`
if [ "$RUNNER_OS" != "Windows" ]; then
mxtest --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=${{ matrix.CC }}_CHANGES $PERMISSIVE
else
export COMPILIST=`echo $COMPILIST template_simple`
echo .\\install\\bin\\mxtest --verbose --testdir run_${comp} --comp=${comp} --suffix=${{ matrix.CC }}_CHANGES --permissive >> ..\\changedinstr.bat
fi
done
else
export RUNALL="YES"
echo No matching tests found
fi
done
fi
export RUNALL="NO"
export CHANGEDINSTR=`git diff --name-only HEAD HEAD~1| grep \.instr\$ | grep mcxtrace-comps | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export CHANGEDINSTR=`echo $CHANGEDINSTR $COMPILIST | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export CHANGEDINSTR=`echo $CHANGEDINSTR | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export NUMCHANGEDINSTR=`git diff --name-only HEAD HEAD~1|grep \.instr\$ | grep mcxtrace-comps | wc -l | xargs echo`
echo ----
echo $NUMCHANGEDCOMPS components and $NUMCHANGEDINSTR instruments were changed, resulting in this list:
Expand All @@ -436,24 +434,20 @@ jobs:
then
export RUNALL="YES"
fi
export PERMISSIVE=" "
if [ "$NUMCHANGEDINSTR" != "0" ] || [ "$NUMCHANGEDCOMPS" != "0" ];
if [ "$NUMCHANGEDINSTR" != "0" ];
then
if [ "$RUNALL" == "NO" ];
then
export SCOPE="--instr=$CHANGEDINSTR"
else
export SCOPE=" "
fi
mkdir run_mxtest && cd run_mxtest
if [ "$RUNNER_OS" != "Windows" ]; then
mkdir run_mxtest && cd run_mxtest
if [ "$RUNNER_OS" == macOS ]; then
export PERMISSIVE="--permissive"
fi
../install_mcxtrace/bin/${MXTEST_EXECUTABLE} --testdir $PWD $SCOPE --suffix=${{ matrix.CC }}_CHANGES $PERMISSIVE
mxtest --mpi=2 --testdir $PWD $SCOPE --suffix=${{ matrix.CC }}_CHANGES $PERMISSIVE
mxviewtest --nobrowse $PWD
else
echo ..\\install\\bin\\mxtest --verbose --testdir=. $SCOPE --suffix=${{ matrix.CC }}_CHANGES --permissive > changedinstr.bat
echo .\\install\\bin\\mxtest --verbose --testdir=run_mxtest $SCOPE --suffix=${{ matrix.CC }}_CHANGES --permissive >> ..\\changedinstr.bat
fi
fi

Expand All @@ -465,9 +459,7 @@ jobs:
shell: cmd
run: |
if exist changedinstr.bat (
mkdir run_mxtest
cd run_mxtest
call ..\changedinstr.bat
call .\changedinstr.bat
)

# Start of Windows tests
Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/mcxtrace-conda-basictest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,35 +199,33 @@ jobs:
export MCXTRACE_EXECUTABLE="mcxtrace"
export MXRUN_EXECUTABLE="mxrun"
export MXTEST_EXECUTABLE="mxtest"
export PERMISSIVE=" "
export PATH=${PATH}:${PWD}/install_mcxtrace/bin/:${PWD}/install_mcxtrace/mcxtrace/3.99.99/bin/
# Check if any instr files were modified during last commit
cd src
export CHANGEDCOMPS=`git diff --name-only HEAD HEAD~1| grep \.comp\$ | grep mcxtrace-comps | xargs -n1 basename | sed s/\.comp//g | xargs echo`
export NUMCHANGEDCOMPS=`git diff --name-only HEAD HEAD~1|grep \.comp\$ | grep mcxtrace-comps | wc -l | xargs echo`
export COMPILIST=""
export RUNALL="NO"
if [ "$NUMCHANGEDCOMPS" != "0" ];
then
if [ "$NUMCHANGEDCOMPS" -lt "20" ];
then
for comp in $CHANGEDCOMPS;
do
echo Finding instruments matching component $comp
echo Finding tests including component $comp
NUMMATCH=`find mcxtrace-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | wc -l`
if [ "$NUMMATCH" -gt "0" ];
then
MATCH=`find mcxtrace-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export COMPILIST=`echo $COMPILIST $MATCH`
if [ "$RUNNER_OS" != "Windows" ]; then
mxtest --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES $PERMISSIVE
else
export COMPILIST=`echo $COMPILIST template_simple`
mxtest.bat --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES $PERMISSIVE
fi
done
else
export RUNALL="YES"
echo No matching tests found
fi
done
fi
export RUNALL="NO"
export CHANGEDINSTR=`git diff --name-only HEAD HEAD~1| grep \.instr\$ | grep mcxtrace-comps | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export CHANGEDINSTR=`echo $CHANGEDINSTR $COMPILIST | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export CHANGEDINSTR=`echo $CHANGEDINSTR | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export NUMCHANGEDINSTR=`git diff --name-only HEAD HEAD~1|grep \.instr\$ | grep mcxtrace-comps | wc -l | xargs echo`
echo ----
echo $NUMCHANGEDCOMPS components and $NUMCHANGEDINSTR instruments were changed, resulting in this list:
Expand All @@ -238,8 +236,7 @@ jobs:
then
export RUNALL="YES"
fi
export PERMISSIVE=" "
if [ "$NUMCHANGEDINSTR" != "0" ] || [ "$NUMCHANGEDCOMPS" != "0" ];
if [ "$NUMCHANGEDINSTR" != "0" ];
then
if [ "$RUNALL" == "NO" ];
then
Expand Down
4 changes: 2 additions & 2 deletions tools/Python/mccodelib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,13 @@ def get_instr_comp_files(mydir, recursive=True, instrfilter=None, withcomp=None,
instrreg = re.compile(filter)
if instrreg.search(join(dirpath,f), re.IGNORECASE):
if withcomp is not None:
if withcomp in Path(join(dirpath, f)).read_text():
if withcomp in Path(join(dirpath, f)).read_text(encoding="utf8"):
files_instr.append(join(dirpath, f))
else:
files_instr.append(join(dirpath, f))
else:
if withcomp is not None:
if withcomp in Path(join(dirpath, f)).read_text():
if withcomp in Path(join(dirpath, f)).read_text(encoding="utf8"):
files_instr.append(join(dirpath, f))
else:
files_instr.append(join(dirpath, f))
Expand Down
Loading