diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2022-06-06 11:20:05 +0100 |
---|---|---|
committer | Stephen Tozer <stephen.tozer@sony.com> | 2022-06-08 16:28:27 +0100 |
commit | b03451bb9acea1bea2ad02d280e5a5f0547b8a17 (patch) | |
tree | d62e1117f5bfa2b5420a661aa9468114f14925fd /cross-project-tests/debuginfo-tests | |
parent | e4ba24c17d2ee8db0e8dd166d7700aa9dd083770 (diff) | |
download | llvm-b03451bb9acea1bea2ad02d280e5a5f0547b8a17.tar.gz |
[Dexter] Use PurePath to compare paths in Dexter commands
Prior to this patch, when comparing the paths of source files in Dexter
commands, we would use os.samefile. This function performs actual file
operations and requires the files to exist on the current system; this
is suitable when running the test for the first time, but renders the
DextIR output files non-portable, and unusable if the source files no
longer exist in their original location.
Differential Revision: https://reviews.llvm.org/D127099
Diffstat (limited to 'cross-project-tests/debuginfo-tests')
3 files changed, 8 insertions, 7 deletions
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexDeclareAddress.py b/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexDeclareAddress.py index 708fc2760e03..29d2dc761074 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexDeclareAddress.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexDeclareAddress.py @@ -8,6 +8,7 @@ """ import os +from pathlib import PurePath from dex.command.CommandBase import CommandBase, StepExpectInfo @@ -37,13 +38,12 @@ class DexDeclareAddress(CommandBase): return self.addr_name def eval(self, step_collection): - assert os.path.exists(self.path) self.address_resolutions[self.get_address_name()] = None for step in step_collection.steps: loc = step.current_location - if (loc.path and os.path.exists(loc.path) and - os.path.samefile(loc.path, self.path) and + if (loc.path and self.path and + PurePath(loc.path) == PurePath(self.path) and loc.lineno == self.on_line): if self.hit_count > 0: self.hit_count -= 1 diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexExpectWatchBase.py b/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexExpectWatchBase.py index 44c8bdbe0f25..6dd30adac289 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexExpectWatchBase.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexExpectWatchBase.py @@ -14,6 +14,7 @@ import difflib import os import math from collections import namedtuple +from pathlib import PurePath from dex.command.CommandBase import CommandBase, StepExpectInfo from dex.command.StepValueInfo import StepValueInfo @@ -208,12 +209,11 @@ class DexExpectWatchBase(CommandBase): return differences def eval(self, step_collection): - assert os.path.exists(self.path) for step in step_collection.steps: loc = step.current_location - if (loc.path and os.path.exists(loc.path) and - os.path.samefile(loc.path, self.path) and + if (loc.path and self.path and + PurePath(loc.path) == PurePath(self.path) and loc.lineno in self.line_range): try: watch = step.program_state.frames[0].watches[self.expression] diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/dextIR/ProgramState.py b/cross-project-tests/debuginfo-tests/dexter/dex/dextIR/ProgramState.py index 4f05189aed8b..a1de5fbcf363 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/dextIR/ProgramState.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/dextIR/ProgramState.py @@ -11,6 +11,7 @@ fixed point in execution. import os from collections import OrderedDict +from pathlib import PurePath from typing import List class SourceLocation: @@ -31,7 +32,7 @@ class SourceLocation: if not other or not isinstance(other, SourceLocation): return False - if self.path and (self.path != other.path): + if self.path and (other.path is None or (PurePath(self.path) != PurePath(other.path))): return False if self.lineno and (self.lineno != other.lineno): |