Skip to content

Instantly share code, notes, and snippets.

@aabccd021
Created May 12, 2025 01:21
Show Gist options
  • Select an option

  • Save aabccd021/7da84b2f1e4e6625a2a93d00ec5967fc to your computer and use it in GitHub Desktop.

Select an option

Save aabccd021/7da84b2f1e4e6625a2a93d00ec5967fc to your computer and use it in GitHub Desktop.
check duplicate scenario
{
checkDuplicateScenario = pkgs.runCommand "checkDuplicateScenario"
{ env.HISTORIES = "${snapshot-scenarioHistories}/test/scenario-histories"; } ''
scenarioDirFiles=$(ls "$HISTORIES")
checked=""
for scenario1 in $scenarioDirFiles; do
for scenario2 in $scenarioDirFiles; do
if [ "$scenario1" = "$scenario2" ]; then
continue
fi
if echo "$checked" | grep -q " $scenario2 "; then
continue
fi
if [ ! -f "./$scenario1" ]; then
cat "$HISTORIES/$scenario1" | cut -d' ' -f2- > "./$scenario1"
fi
if [ ! -f "./$scenario2" ]; then
cat "$HISTORIES/$scenario2" | cut -d' ' -f2- > "./$scenario2"
fi
if [ "$(diff -q $scenario1 $scenario2)" = "" ]; then
echo "Duplicate scenario found: $scenario1 and $scenario2"
exit 1
fi
done
checked="$checked $scenario1"
done
touch $out
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment