Files
mercury/tools/make_java_csharp_arena_base
Zoltan Somogyi 1bed6fd2cc Add tools for checking Java and C# output.
tools/make_java_csharp_arena_base:
tools/make_java_csharp_arena_diff:
    Add these scripts, which can be used to check whether the output
    of a new compiler in Java and C# grades is bit-identical to the output
    of a known-good old compiler. This is particularly useful on machines
    that can't check the correctness of the output in these grades
    because they don't have Java or C# compilers installed.
2017-07-13 13:12:51 +02:00

74 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
# vim: ft=sh ts=4 sw=4 et
#
# This script is intended to be used to check whether a new version
# of the Mercury compiler generates bit-identical output to an old version
# when generating Java and C# code. We need this ability to avoid introducing
# regressions on machines that don't have Java and/or C# compilers installed,
# but it can be useful even on machines that do have them installed.
#
# The job of this script is to set up the basis for comparison using
# the output from an old, known good compiler; the companion script
# make_java_csharp_diff will then compare this to the output of the new,
# compiler being tested. The two scripts are separate because during
# a typical development effort, the second part typically needs to be done
# significantly more times than the first :-(
#
# The user should set the environment variable named BASE_MMC to contain
# the invocation of the known-good compiler (typically either "mmc" or
# an instance of tools/lmc) and the environment variable named TEST_MMC
# to contain the invocation of the compiler under test (typically
# an instance of tools/lmc). The latter is used by make_java_csharp_diff.
#
# This script creates a directory named arena.base that contains
# all the Mercury source files and interface files from all of the
# Mercury modules in main Mercury directories of the workspace,
# and then it puts the known good outputs for the Java and C# grades
# in arena.base.java and arena.base.csharp respectively.
# The companion script make_java_csharp_diff then puts the output
# of the compiler under test in those grades in arena.java and arena.csharp
# respectively, and compares them to their respective bases.
if test "${BASE_MMC}" = ""
then
echo "make_java_csharp_base: you need to set BASE_MMC in the environment"
exit 1
fi
dirs="library mdbcomp browser compiler slice profiler deep_profiler"
root=`/bin/pwd`
cd ${root}
/bin/rm -fr arena.base arena.base.java arena.base.csharp > /dev/null 2>&1
mkdir arena.base
for d in ${dirs}
do
cp ${d}/*.m arena.base
cp ${d}/*.int* arena.base
cp ${d}/*.d* arena.base
done
cd ${root}/arena.base
${BASE_MMC} -f *.m
cd ${root}
cp -rp arena.base arena.base.java
cd ${root}/arena.base.java
for f in *.m
do
echo === JAVA ${f} ===
${BASE_MMC} --grade java --target-code-only ${f}
done
cd ${root}
cp -rp arena.base arena.base.csharp
cd ${root}/arena.base.csharp
for f in *.m
do
echo === CSHARP ${f} ===
${BASE_MMC} --grade csharp --target-code-only ${f}
done
exit 0