Commit 2a9a130b by Miodrag Milanovic

Use python script instead of shell script

parent b4b4fdeb
PYTHON_EXECUTABLE := $(shell if python3 -c ""; then echo "python3"; else echo "python"; fi)
all:: run-test.mk all:: run-test.mk
@touch .stamp @touch .stamp
@$(MAKE) -f run-test.mk @$(MAKE) -f run-test.mk
...@@ -5,7 +7,7 @@ clean:: run-test.mk ...@@ -5,7 +7,7 @@ clean:: run-test.mk
@rm -f .stamp @rm -f .stamp
@$(MAKE) -f run-test.mk clean @$(MAKE) -f run-test.mk clean
run-test.mk: run-test.sh run-test.mk: generate.py
@./run-test.sh @$(PYTHON_EXECUTABLE) generate.py > run-test.mk
.PHONY: all clean .PHONY: all clean
import os
is_heavy_enabled = int(os.getenv('ENABLE_HEAVY_TESTS', '0')) == 1
for root, dirs, files in sorted(os.walk(".")):
for file in files:
if file.endswith('.ys'):
dir = os.path.basename(root)
work = os.path.splitext(file)[0]
heavy = os.path.exists(os.path.join(dir, "heavy_test"))
print("all:: {0}/work_{1}/.stamp\n"
"{0}/work_{1}/.stamp:".format(dir, work))
if (heavy and not is_heavy_enabled):
print("\t@echo 'Skipping heavy test {0}..'".format(dir, work))
continue
print("\t@echo 'Running {2}{1}..'\n"
"\t@./run.sh {0} {1}\n"
"clean::\n"
"\t@echo 'Cleaning {1}..'\n"
"\t@rm -rf {0}/work_{1}".format(dir, work, "heavy " if heavy else ""))
print(".PHONY: all clean")
\ No newline at end of file
#!/usr/bin/env bash
set -e
{
for x in *; do
if [ -d "$x" ]; then
if [ -f "$x/$x.ys" ]; then
# Running test expected to pass
echo "all:: $x/work_$x/.stamp"
echo "$x/work_$x/.stamp:"
if [ -f "$x/heavy_test" ]; then
if [ -z "$ENABLE_HEAVY_TESTS" ] || [ "$ENABLE_HEAVY_TESTS" -ne "1" ]; then
echo " @echo 'Skipping heavy test $x..'"
continue
fi
echo " @echo 'Running heavy test $x..'"
else
echo " @echo 'Running $x..'"
fi
echo " @./run.sh $x $x"
echo "clean::"
echo " @echo 'Cleaning $x..'"
echo " @rm -rf $x/work_$x"
elif [ -f "$x/$x""_fail.ys" ]; then
# Running test expected to fail
echo "all:: $x/work_$x""_fail/.stamp"
echo "$x/work_$x""_fail/.stamp:"
if [ -f "$x/heavy_test" ]; then
if [ -z "$ENABLE_HEAVY_TESTS" ] || [ "$ENABLE_HEAVY_TESTS" -ne "1" ]; then
echo " @echo 'Skipping heavy test $x..'"
continue
fi
echo " @echo 'Running heavy test $x..'"
else
echo " @echo 'Running $x..'"
fi
echo " @./run.sh $x $x""_fail"
echo "clean::"
echo " @echo 'Cleaning $x..'"
echo " @rm -rf $x/work_$x""_fail"
else
# In case there is no script fail makefile
echo "all:: run-$x"
echo "run-$x:"
echo " \$(error 'No scripts in $x..')"
fi
fi
done
echo ".PHONY: all clean"
} > run-test.mk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment