tests/extra/tc_ufcs_all_kinds: support gdc
Change the format in which errors are printed to keep it consistent across all the three major compilers (a style that they all support is the gnu style) and make the matching code in generate_tests.d more readable by using a regex. Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
This commit is contained in:
parent
dd28e52ec1
commit
45117876d8
|
|
@ -31,6 +31,8 @@ stdout.txt
|
||||||
# script-generated expected with absolute file paths
|
# script-generated expected with absolute file paths
|
||||||
tests/tc_locate_ufcs_function/expected.txt
|
tests/tc_locate_ufcs_function/expected.txt
|
||||||
tests/tc_recursive_public_import/expected.txt
|
tests/tc_recursive_public_import/expected.txt
|
||||||
|
# other script-generated files
|
||||||
|
tests/extra/tc_ufcs_all_kinds/generate_tests
|
||||||
|
|
||||||
# Dub files
|
# Dub files
|
||||||
.dub
|
.dub
|
||||||
|
|
|
||||||
|
|
@ -129,29 +129,27 @@ int main(string[] args)
|
||||||
|
|
||||||
fs.write("proc_test.d", code);
|
fs.write("proc_test.d", code);
|
||||||
|
|
||||||
auto output = executeShell("$DC -verrors=0 -c proc_test.d").output;
|
auto output = executeShell("$DC -verrors=0 $ERROR_STYLE -c proc_test.d").output;
|
||||||
|
|
||||||
size_t numErrors = 0;
|
size_t numErrors = 0;
|
||||||
|
|
||||||
string[][string] variableIncompatibilities;
|
string[][string] variableIncompatibilities;
|
||||||
|
|
||||||
|
// Example of a line we want to match: `proc_test.d:2568:22: error: [...]'
|
||||||
|
auto errRegex = regex(`proc_test\.d:([0-9]*):[0-9]*: error`, "i");
|
||||||
foreach (err; output.lineSplitter)
|
foreach (err; output.lineSplitter)
|
||||||
{
|
{
|
||||||
if (!err.startsWith("proc_test.d("))
|
if (auto m = matchFirst(err, errRegex)) {
|
||||||
continue;
|
auto lineNo = to!int(m[1]);
|
||||||
err = err["proc_test.d(".length .. $];
|
string line = lines[lineNo - 1];
|
||||||
auto lineNo = err.parse!int;
|
enforce(line.endsWith("();"), "Unexpected error in line " ~ lineNo.to!string);
|
||||||
if (!err.startsWith("): Error: "))
|
line = line[0 .. $ - 3];
|
||||||
continue;
|
string varName = line.findSplit(".")[0];
|
||||||
err = err["): Error: ".length .. $];
|
string funcName = line.findSplit(".")[2];
|
||||||
string line = lines[lineNo - 1];
|
// writeln("variable type ", varLookup[varName], " can't call ", funcLookup[funcName]);
|
||||||
enforce(line.endsWith("();"), "Unexpected error in line " ~ lineNo.to!string);
|
variableIncompatibilities[varName] ~= funcName;
|
||||||
line = line[0 .. $ - 3];
|
numErrors++;
|
||||||
string varName = line.findSplit(".")[0];
|
}
|
||||||
string funcName = line.findSplit(".")[2];
|
|
||||||
// writeln("variable type ", varLookup[varName], " can't call ", funcLookup[funcName]);
|
|
||||||
variableIncompatibilities[varName] ~= funcName;
|
|
||||||
numErrors++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enforce(numErrors > 1_000, "compiler didn't error as expected, need to adjust tests!");
|
enforce(numErrors > 1_000, "compiler didn't error as expected, need to adjust tests!");
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,19 @@ if [ -z "${DC:-}" ]; then
|
||||||
DC=dmd
|
DC=dmd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DC="$DC" "$DC" -run generate_tests.d "$1"
|
DCBASE=$(basename "${DC}")
|
||||||
|
|
||||||
|
# Set up ERROR_STYLE to make all compilers output errors in the same
|
||||||
|
# format to make matching easier in generate_tests.d.
|
||||||
|
|
||||||
|
if [[ ${DCBASE} =~ gdmd ]]; then
|
||||||
|
ERROR_STYLE=
|
||||||
|
elif [[ ${DCBASE} =~ dmd|ldc ]]; then
|
||||||
|
ERROR_STYLE='-verror-style=gnu -vcolumns'
|
||||||
|
else
|
||||||
|
echo "unknonwn compiler ${DC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export DC ERROR_STYLE
|
||||||
|
${DC} -run generate_tests.d "${1}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue