mirror of
https://codeberg.org/ziglings/exercises.git
synced 2024-12-27 01:46:29 +00:00
Patch/test scripts now run from project root
This simplifies everything and makes everything good. (Shell scripts need to be as simple as possible for maximum compatibility.)
This commit is contained in:
parent
8b4b8b166f
commit
d560c41b59
2 changed files with 25 additions and 20 deletions
|
@ -13,19 +13,22 @@
|
||||||
# to convalesce in the healed directory.
|
# to convalesce in the healed directory.
|
||||||
#
|
#
|
||||||
|
|
||||||
# We run from the patches dir. Go there now if not already.
|
# We check ourselves before we wreck ourselves.
|
||||||
cd $(dirname $(realpath $0))
|
if [ ! -f 'patches/eowyn.sh' ]
|
||||||
pwd # Show it upon the screen so all shall be made apparent.
|
then
|
||||||
|
echo "But I must be run from the project root directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Create healed/ directory here if it doesn't already exist.
|
# Create directory of healing if it doesn't already exist.
|
||||||
mkdir -p healed
|
mkdir -p patches/healed
|
||||||
|
|
||||||
# Cycle through all the little broken Zig applications.
|
# Cycle through all the little broken Zig applications.
|
||||||
for broken in ../exercises/*.zig
|
for broken in exercises/*.zig
|
||||||
do
|
do
|
||||||
# Remove the dir and extension, rendering the True Name.
|
# Remove the dir and extension, rendering the True Name.
|
||||||
true_name=$(basename $broken .zig)
|
true_name=$(basename $broken .zig)
|
||||||
patch_name="patches/$true_name.patch"
|
patch_name="patches/patches/$true_name.patch"
|
||||||
|
|
||||||
|
|
||||||
if [ -f $patch_name ]
|
if [ -f $patch_name ]
|
||||||
|
@ -33,14 +36,11 @@ do
|
||||||
# Apply the bandages to the wounds, grow new limbs, let
|
# Apply the bandages to the wounds, grow new limbs, let
|
||||||
# new life spring into the broken bodies of the fallen.
|
# new life spring into the broken bodies of the fallen.
|
||||||
echo Healing $true_name...
|
echo Healing $true_name...
|
||||||
patch --output=healed/$true_name.zig $broken $patch_name
|
patch --output=patches/healed/$true_name.zig $broken $patch_name
|
||||||
else
|
else
|
||||||
echo Cannot heal $true_name. No patch found.
|
echo Cannot heal $true_name. No patch found.
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Return to the home of our ancestors.
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
# Test the healed exercises. May the compiler have mercy upon us.
|
# Test the healed exercises. May the compiler have mercy upon us.
|
||||||
zig build -Dhealed
|
zig build -Dhealed
|
||||||
|
|
|
@ -6,18 +6,23 @@
|
||||||
# Gollum, The Hobbit, or There and Back Again
|
# Gollum, The Hobbit, or There and Back Again
|
||||||
#
|
#
|
||||||
|
|
||||||
cd $(dirname $(realpath $0))
|
if [ ! -f 'patches/gollum.sh' ]
|
||||||
f=$(basename ../exercises/$1*.zig .zig 2> /dev/null)
|
then
|
||||||
b=../exercises/$f.zig
|
echo "We must be run from the project root dir, precious!"; exit 1
|
||||||
a=../answers/$f.zig
|
fi
|
||||||
p=patches/$f.patch
|
|
||||||
|
|
||||||
printf "\tf: '$f'\n\tb: '$b'\n\ta: '$a'\n"
|
ex=$(printf "%03d" $1)
|
||||||
|
echo "Nassssty exercise $ex..."
|
||||||
|
|
||||||
if [ ! -f $b ]; then echo "We hates it!"; exit 1; fi
|
f=$(basename exercises/${ex}_*.zig .zig 2> /dev/null)
|
||||||
if [ ! -f $a ]; then echo "Where is it? Where is the answer, precious?"; exit; fi
|
b=exercises/$f.zig
|
||||||
|
a=answers/$f.zig
|
||||||
|
p=patches/patches/$f.patch
|
||||||
|
|
||||||
echo Hisssss!
|
if [ ! -f $b ]; then echo "No $f! We hates it!"; exit 1; fi
|
||||||
|
if [ ! -f $a ]; then echo "No $a! Where is it? Where is the answer, precious?"; exit; fi
|
||||||
|
|
||||||
|
echo "Hissss!\tbefore: '$b'\n\t after: '$a'\n\t patch: '$p'\n"
|
||||||
|
|
||||||
diff $b $a > $p
|
diff $b $a > $p
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue