From dc0ca24d52e283b5cb9502c2ade5e5b6eaf4b545 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 2 Sep 2022 21:55:52 +0200 Subject: [PATCH] [MIRROR] Improve validation script annotations [MDB IGNORE] (#15968) * Improve validation script annotations (#69553) We now correctly calculate the offset into the DME file by comparing total lines in vs lines stored. Note this will fail if you ever skip lines in the middle of the file We also show the expected line instead * Improve validation script annotations Co-authored-by: oranges --- tools/validate_dme.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/validate_dme.py b/tools/validate_dme.py index 742fce0aa08..adfa76f9381 100644 --- a/tools/validate_dme.py +++ b/tools/validate_dme.py @@ -14,8 +14,9 @@ FORBID_INCLUDE = [ ] lines = [] - +total = 0 for line in sys.stdin: + total+=1 line = line.strip() if line == "// BEGIN_INCLUDE": @@ -28,6 +29,8 @@ for line in sys.stdin: lines.append(line) +offset = total - len(lines) +print(f"{offset} lines were ignored in output") fail_no_include = False code_files = glob.glob("code/**/*.dm", recursive=True) + glob.glob("modular_skyrat/**/*.dm", recursive=True) # SKYRAT EDIT CHANGE @@ -85,9 +88,8 @@ def compare_lines(a, b): raise f"Two lines were exactly the same ({a} vs. {b})" sorted_lines = sorted(lines, key = functools.cmp_to_key(compare_lines)) - for (index, line) in enumerate(lines): if sorted_lines[index] != line: - print(f"The include at line {index + 1} is out of order ({line})") - print(f"::error file=tgstation.dme,line={index+1},title=DME Validator::The include at line {index + 1} is out of order ({line})") + print(f"The include at line {index + offset} is out of order ({line}, expected {sorted_lines[index]})") + print(f"::error file=tgstation.dme,line={index+offset},title=DME Validator::The include at line {index + offset} is out of order ({line}, expected {sorted_lines[index]})") sys.exit(1)