Skip to content

Commit 66e39ab

Browse files
Rollup merge of #164201 - Walnut356:unsigned_unpack, r=Kobzol
Improve `--bless` output for `tests/debuginfo` Fixes a few small things that came up while writing a new test. The first commit fixes a small bug that caused unsigned integer values to be unpacked as signed values. The second forces `\n` line endings, which makes running `--bless` less annoying on windows. Python defaults to platform specific line-endings by default. I think git normalizes away the differences anyway? But when working, they'd show up as changed files, so this just prevents those phantom diffs. The bigger change in the second commit is sorting the types dictionary, which should help prevent diffs that are just shuffling types around. For reference, python (3.7+) dictionaries are in insertion order by default, so adding a new variable could sometimes cause a type to be processed sooner or later than it had been before. All other list/dict instances *are* order-sensitive and/or changing their position has significance in the test, so those have remained the same. r? @jieyouxu, @Kobzol
2 parents 00c6f85 + a2d2de0 commit 66e39ab

5 files changed

Lines changed: 472 additions & 465 deletions

File tree

‎src/etc/debugger_tester/common.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,13 @@ def save_blessing(self, metadata: BlessMetadata):
551551

552552
self.bless_metadata = metadata
553553
path = os.environ["DEBUGGER_TESTER_INPUT_DATA_PATH"]
554+
555+
# We first sort the types dictionary. This keeps the git diff more consistent, and doesn't
556+
# affect runtime behavior at all.
557+
import operator
558+
559+
self.types = dict(sorted(self.types.items(), key=operator.itemgetter(0)))
560+
554561
# dumping directly to a file is somewhat unsafe. If the `Variable`/`Type` data ends up in a
555562
# state that cannot be serialized correctly, the json ends up malformed, and we could end up
556563
# overwriting valid test data with a complete mess. Since the in-memory data is typically
@@ -567,7 +574,7 @@ def save_blessing(self, metadata: BlessMetadata):
567574

568575
os.makedirs(pathlib.Path(path).parent, exist_ok=True)
569576

570-
with open(path, "w") as f:
577+
with open(path, "w", newline="\n") as f:
571578
f.write(x)
572579
f.write("\n")
573580

‎src/etc/debugger_tester/lldb/from_lldb.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def type_unpack_fmt(kind: int, size: int) -> str:
127127
fmt = _SIZE_TO_INT_FMT[size]
128128

129129
if kind in _UNSIGNED_INT_TYPES:
130-
fmt.upper()
130+
fmt = fmt.upper()
131131

132132
return fmt
133133

0 commit comments

Comments
 (0)