Skip to content

Commit f350b6a

Browse files
authored
Revert "[lldb] Migrate distutils.version.LooseVersion to packaging (#82066)"
This reverts commit 13dce35.
1 parent 61ae7e4 commit f350b6a

File tree

5 files changed

+36
-40
lines changed

5 files changed

+36
-40
lines changed

lldb/packages/Python/lldbsuite/test/decorators.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# System modules
2+
from distutils.version import LooseVersion
23
from functools import wraps
3-
from pkg_resources import packaging
44
import ctypes
55
import locale
66
import os
@@ -65,10 +65,10 @@ def fn_neq(x, y):
6565
">=": fn_geq,
6666
"<=": fn_leq,
6767
}
68+
expected_str = ".".join([str(x) for x in expected])
69+
actual_str = ".".join([str(x) for x in actual])
6870

69-
return op_lookup[comparison](
70-
packaging.version.parse(actual), packaging.version.parse(expected)
71-
)
71+
return op_lookup[comparison](LooseVersion(actual_str), LooseVersion(expected_str))
7272

7373

7474
def _match_decorator_property(expected, actual):
@@ -238,9 +238,7 @@ def fn(actual_debug_info=None):
238238
)
239239
)
240240
skip_for_py_version = (py_version is None) or _check_expected_version(
241-
py_version[0],
242-
py_version[1],
243-
"{}.{}".format(sys.version_info.major, sys.version_info.minor),
241+
py_version[0], py_version[1], sys.version_info
244242
)
245243
skip_for_macos_version = (macos_version is None) or (
246244
(platform.mac_ver()[0] != "")

lldb/packages/Python/lldbsuite/test/lldbplatformutil.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import subprocess
88
import sys
99
import os
10+
from distutils.version import LooseVersion
1011
from urllib.parse import urlparse
11-
from pkg_resources import packaging
1212

1313
# LLDB modules
1414
import lldb
@@ -297,30 +297,27 @@ def expectedCompilerVersion(compiler_version):
297297
if compiler_version is None:
298298
return True
299299
operator = str(compiler_version[0])
300-
version_str = str(compiler_version[1])
300+
version = compiler_version[1]
301301

302-
if not version_str:
302+
if version is None:
303303
return True
304304

305-
test_compiler_version_str = getCompilerVersion()
306-
if test_compiler_version_str == "unknown":
305+
test_compiler_version = getCompilerVersion()
306+
if test_compiler_version == "unknown":
307307
# Assume the compiler version is at or near the top of trunk.
308308
return operator in [">", ">=", "!", "!=", "not"]
309309

310-
version = packaging.version.parse(version_str)
311-
test_compiler_version = packaging.version.parse(test_compiler_version_str)
312-
313310
if operator == ">":
314-
return test_compiler_version < version
311+
return LooseVersion(test_compiler_version) > LooseVersion(version)
315312
if operator == ">=" or operator == "=>":
316-
return test_compiler_version >= version
313+
return LooseVersion(test_compiler_version) >= LooseVersion(version)
317314
if operator == "<":
318-
return test_compiler_version < version
315+
return LooseVersion(test_compiler_version) < LooseVersion(version)
319316
if operator == "<=" or operator == "=<":
320-
return test_compiler_version <= version
317+
return LooseVersion(test_compiler_version) <= LooseVersion(version)
321318
if operator == "!=" or operator == "!" or operator == "not":
322-
return version_str not in test_compiler_version_str
323-
return version_str in test_compiler_version_str
319+
return str(version) not in str(test_compiler_version)
320+
return str(version) in str(test_compiler_version)
324321

325322

326323
def expectedCompiler(compilers):
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
"""
2-
This is a sanity check that verifies that test can be skipped based on settings.
2+
This is a sanity check that verifies that test can be sklipped based on settings.
33
"""
44

5+
56
import lldb
67
from lldbsuite.test.lldbtest import *
78
from lldbsuite.test.decorators import *
89

910

1011
class SettingSkipSanityTestCase(TestBase):
1112
NO_DEBUG_INFO_TESTCASE = True
12-
CURRENT_PYTHON_VERSION = "3.0"
1313

14-
@skipIf(py_version=(">=", CURRENT_PYTHON_VERSION))
14+
@skipIf(py_version=(">=", (3, 0)))
1515
def testSkip(self):
16-
self.assertTrue(False, "This test should not run and fail (SKIPPED)")
17-
18-
@skipIf(py_version=("<", CURRENT_PYTHON_VERSION))
19-
def testNoSKip(self):
20-
self.assertTrue(True, "This test should run and pass(PASS)")
16+
"""This setting is on by default"""
17+
self.assertTrue(False, "This test should not run!")
2118

22-
@expectedFailureAll(py_version=(">=", CURRENT_PYTHON_VERSION))
23-
def testXFAIL(self):
24-
self.assertTrue(False, "This test should expectedly fail (XFAIL)")
25-
26-
@expectedFailureAll(py_version=("<", CURRENT_PYTHON_VERSION))
27-
def testNotXFAIL(self):
28-
self.assertTrue(True, "This test should pass (PASS)")
19+
@skipIf(py_version=("<", (3, 0)))
20+
def testNoMatch(self):
21+
self.assertTrue(True, "This test should run!")
2922

3023
@skipIf(setting=("target.i-made-this-one-up", "true"))
3124
def testNotExisting(self):
3225
self.assertTrue(True, "This test should run!")
26+
27+
@expectedFailureAll(py_version=(">=", (3, 0)))
28+
def testXFAIL(self):
29+
self.assertTrue(False, "This test should run and fail!")
30+
31+
@expectedFailureAll(py_version=("<", (3, 0)))
32+
def testNotXFAIL(self):
33+
self.assertTrue(True, "This test should run and succeed!")

lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):
6161

6262
# Older versions of watchOS (<7.0) only support i386
6363
if platform_name == "watchos":
64-
from pkg_resources import packaging
64+
from distutils.version import LooseVersion
6565

66-
if packaging.version.parse(vers) < packaging.version.parse("7.0"):
66+
if LooseVersion(vers) < LooseVersion("7.0"):
6767
arch = "i386"
6868

6969
triple = "-".join([arch, "apple", platform_name + vers, "simulator"])

lldb/test/Shell/helper/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ def _find_windows_sdk_in_registry_view(self, view):
519519

520520
# Windows SDK version numbers consist of 4 dotted components, so we
521521
# have to use LooseVersion, as StrictVersion supports 3 or fewer.
522-
from pkg_resources import packaging
522+
from distutils.version import LooseVersion
523523

524-
sdk_versions.sort(key=lambda x: packaging.version.parse(x), reverse=True)
524+
sdk_versions.sort(key=lambda x: LooseVersion(x), reverse=True)
525525
option_value_name = "OptionId.DesktopCPP" + self.msvc_arch_str
526526
for v in sdk_versions:
527527
try:

0 commit comments

Comments
 (0)