From d465ba5356a90a6a2c15b7b05b5c7f3eea5ff7df Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sun, 25 Aug 2024 18:26:44 +0200 Subject: [PATCH] `--test` will now provide the full filename and the column. --- releasenotes.md | 1 + src/compiler/diagnostics.c | 4 ++-- test/src/tester.py | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/releasenotes.md b/releasenotes.md index 608087ae0..f85bd6502 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -85,6 +85,7 @@ - Compiler didn't detect when a module name was used both as a generic and regular module. - Assigning a const zero to an aliased distinct caused an error. - `--path` is now properly respected. +- `--test` will now provide the full filename and the column. ### Stdlib changes diff --git a/src/compiler/diagnostics.c b/src/compiler/diagnostics.c index b2c9602ce..89e14bb6a 100644 --- a/src/compiler/diagnostics.c +++ b/src/compiler/diagnostics.c @@ -24,13 +24,13 @@ static void print_error_type_at(SourceSpan location, const char *message, PrintT switch (print_type) { case PRINT_TYPE_ERROR: - eprintf("Error|%s|%d|%s\n", file->name, location.row, message); + eprintf("Error|%s|%d|%d|%s\n", file->full_path, location.row, location.col, message); return; case PRINT_TYPE_NOTE: // Note should not be passed on. return; case PRINT_TYPE_WARN: - eprintf("Warning|%s|%d|%s\n", file->name, location.row, message); + eprintf("Warning|%s|%d|%d|%s\n", file->full_path, location.row, location.col, message); return; default: UNREACHABLE diff --git a/test/src/tester.py b/test/src/tester.py index 314f2c609..cff92f73e 100644 --- a/test/src/tester.py +++ b/test/src/tester.py @@ -79,7 +79,7 @@ class Issues: print(" Failed.") self.has_errors = True - def check_line(self, typ, file, line, message): + def check_line(self, typ, file, line, col, message): map_ = {} if typ == 'Error': map_ = self.errors @@ -87,6 +87,7 @@ class Issues: map_ = self.warnings else: self.exit_error("Unknown type: " + typ) + file = os.path.basename(file) key = file + ":" + line value = map_.get(key) if value is None: @@ -99,10 +100,10 @@ class Issues: def parse_result(self, lines): for line in lines: - parts = line.split('|', maxsplit=4) - if len(parts) != 4: + parts = line.split('|', maxsplit=5) + if len(parts) != 5: self.exit_error("Illegal error result: " + line) - if not self.check_line(parts[0], parts[1], parts[2], parts[3]): + if not self.check_line(parts[0], parts[1], parts[2], parts[3], parts[4]): self.set_failed() print("Unexpected " + parts[0].lower() + " in " + parts[1] + " line " + parts[2] + ":", end="") print('"' + parts[3] + '"')