Skip to content

Revert "[lldb] Migrate distutils.version.LooseVersion to packaging" #82297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

JDevlieghere
Copy link
Member

@llvmbot llvmbot added the lldb label Feb 20, 2024
@JDevlieghere JDevlieghere merged commit 71e0623 into main Feb 20, 2024
@JDevlieghere JDevlieghere deleted the revert-82066-distutils-migration branch February 20, 2024 01:46
@llvmbot
Copy link
Member

llvmbot commented Feb 20, 2024

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Reverts llvm/llvm-project#82066 because the following tests started failing after:

lldb-api.commands/expression/import-std-module/deque-basic.TestDequeFromStdModule.py
lldb-api.commands/expression/import-std-module/deque-dbg-info-content.TestDbgInfoContentDequeFromStdModule.py
lldb-api.commands/expression/import-std-module/forward_list.TestForwardListFromStdModule.py
lldb-api.commands/expression/import-std-module/forward_list-dbg-info-content.TestDbgInfoContentForwardListFromStdModule.py
lldb-api.commands/expression/import-std-module/list.TestListFromStdModule.py
lldb-api.commands/expression/import-std-module/non-module-type-separation.TestNonModuleTypeSeparation.py
lldb-api.commands/expression/import-std-module/queue.TestQueueFromStdModule.py
lldb-api.commands/expression/import-std-module/retry-with-std-module.TestRetryWithStdModule.py
lldb-api.commands/expression/import-std-module/unique_ptr.TestUniquePtrFromStdModule.py
lldb-api.commands/expression/import-std-module/unique_ptr-dbg-info-content.TestUniquePtrDbgInfoContent.py
lldb-api.commands/expression/import-std-module/vector-of-vectors.TestVectorOfVectorsFromStdModule.py
lldb-api.functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr.TestDataFormatterLibcxxSharedPtr.py
lldb-api.functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr.TestDataFormatterLibcxxUniquePtr.py


Full diff: https://github.com/llvm/llvm-project/pull/82297.diff

5 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+5-7)
  • (modified) lldb/packages/Python/lldbsuite/test/lldbplatformutil.py (+11-14)
  • (modified) lldb/test/API/sanity/TestSettingSkipping.py (+16-15)
  • (modified) lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py (+2-2)
  • (modified) lldb/test/Shell/helper/build.py (+2-2)
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index b691f82b90652c..a5d7a7a25879df 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1,6 +1,6 @@
 # System modules
+from distutils.version import LooseVersion
 from functools import wraps
-from pkg_resources import packaging
 import ctypes
 import locale
 import os
@@ -65,10 +65,10 @@ def fn_neq(x, y):
         ">=": fn_geq,
         "<=": fn_leq,
     }
+    expected_str = ".".join([str(x) for x in expected])
+    actual_str = ".".join([str(x) for x in actual])
 
-    return op_lookup[comparison](
-        packaging.version.parse(actual), packaging.version.parse(expected)
-    )
+    return op_lookup[comparison](LooseVersion(actual_str), LooseVersion(expected_str))
 
 
 def _match_decorator_property(expected, actual):
@@ -238,9 +238,7 @@ def fn(actual_debug_info=None):
             )
         )
         skip_for_py_version = (py_version is None) or _check_expected_version(
-            py_version[0],
-            py_version[1],
-            "{}.{}".format(sys.version_info.major, sys.version_info.minor),
+            py_version[0], py_version[1], sys.version_info
         )
         skip_for_macos_version = (macos_version is None) or (
             (platform.mac_ver()[0] != "")
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index a118aa61a6287d..bd92d03e0e2212 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -7,8 +7,8 @@
 import subprocess
 import sys
 import os
+from distutils.version import LooseVersion
 from urllib.parse import urlparse
-from pkg_resources import packaging
 
 # LLDB modules
 import lldb
@@ -297,30 +297,27 @@ def expectedCompilerVersion(compiler_version):
     if compiler_version is None:
         return True
     operator = str(compiler_version[0])
-    version_str = str(compiler_version[1])
+    version = compiler_version[1]
 
-    if not version_str:
+    if version is None:
         return True
 
-    test_compiler_version_str = getCompilerVersion()
-    if test_compiler_version_str == "unknown":
+    test_compiler_version = getCompilerVersion()
+    if test_compiler_version == "unknown":
         # Assume the compiler version is at or near the top of trunk.
         return operator in [">", ">=", "!", "!=", "not"]
 
-    version = packaging.version.parse(version_str)
-    test_compiler_version = packaging.version.parse(test_compiler_version_str)
-
     if operator == ">":
-        return test_compiler_version < version
+        return LooseVersion(test_compiler_version) > LooseVersion(version)
     if operator == ">=" or operator == "=>":
-        return test_compiler_version >= version
+        return LooseVersion(test_compiler_version) >= LooseVersion(version)
     if operator == "<":
-        return test_compiler_version < version
+        return LooseVersion(test_compiler_version) < LooseVersion(version)
     if operator == "<=" or operator == "=<":
-        return test_compiler_version <= version
+        return LooseVersion(test_compiler_version) <= LooseVersion(version)
     if operator == "!=" or operator == "!" or operator == "not":
-        return version_str not in test_compiler_version_str
-    return version_str in test_compiler_version_str
+        return str(version) not in str(test_compiler_version)
+    return str(version) in str(test_compiler_version)
 
 
 def expectedCompiler(compilers):
diff --git a/lldb/test/API/sanity/TestSettingSkipping.py b/lldb/test/API/sanity/TestSettingSkipping.py
index f0d4d266073e03..5f58ec2638456d 100644
--- a/lldb/test/API/sanity/TestSettingSkipping.py
+++ b/lldb/test/API/sanity/TestSettingSkipping.py
@@ -1,7 +1,8 @@
 """
-This is a sanity check that verifies that test can be skipped based on settings.
+This is a sanity check that verifies that test can be sklipped based on settings.
 """
 
+
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
@@ -9,24 +10,24 @@
 
 class SettingSkipSanityTestCase(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
-    CURRENT_PYTHON_VERSION = "3.0"
 
-    @skipIf(py_version=(">=", CURRENT_PYTHON_VERSION))
+    @skipIf(py_version=(">=", (3, 0)))
     def testSkip(self):
-        self.assertTrue(False, "This test should not run and fail (SKIPPED)")
-
-    @skipIf(py_version=("<", CURRENT_PYTHON_VERSION))
-    def testNoSKip(self):
-        self.assertTrue(True, "This test should run and pass(PASS)")
+        """This setting is on by default"""
+        self.assertTrue(False, "This test should not run!")
 
-    @expectedFailureAll(py_version=(">=", CURRENT_PYTHON_VERSION))
-    def testXFAIL(self):
-        self.assertTrue(False, "This test should expectedly fail (XFAIL)")
-
-    @expectedFailureAll(py_version=("<", CURRENT_PYTHON_VERSION))
-    def testNotXFAIL(self):
-        self.assertTrue(True, "This test should pass (PASS)")
+    @skipIf(py_version=("<", (3, 0)))
+    def testNoMatch(self):
+        self.assertTrue(True, "This test should run!")
 
     @skipIf(setting=("target.i-made-this-one-up", "true"))
     def testNotExisting(self):
         self.assertTrue(True, "This test should run!")
+
+    @expectedFailureAll(py_version=(">=", (3, 0)))
+    def testXFAIL(self):
+        self.assertTrue(False, "This test should run and fail!")
+
+    @expectedFailureAll(py_version=("<", (3, 0)))
+    def testNotXFAIL(self):
+        self.assertTrue(True, "This test should run and succeed!")
diff --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index d770447f0771cd..ffac8de6f596ac 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -61,9 +61,9 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):
 
         # Older versions of watchOS (<7.0) only support i386
         if platform_name == "watchos":
-            from pkg_resources import packaging
+            from distutils.version import LooseVersion
 
-            if packaging.version.parse(vers) < packaging.version.parse("7.0"):
+            if LooseVersion(vers) < LooseVersion("7.0"):
                 arch = "i386"
 
         triple = "-".join([arch, "apple", platform_name + vers, "simulator"])
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index d3c25bd944e983..073198a6df2df3 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -519,9 +519,9 @@ def _find_windows_sdk_in_registry_view(self, view):
 
             # Windows SDK version numbers consist of 4 dotted components, so we
             # have to use LooseVersion, as StrictVersion supports 3 or fewer.
-            from pkg_resources import packaging
+            from distutils.version import LooseVersion
 
-            sdk_versions.sort(key=lambda x: packaging.version.parse(x), reverse=True)
+            sdk_versions.sort(key=lambda x: LooseVersion(x), reverse=True)
             option_value_name = "OptionId.DesktopCPP" + self.msvc_arch_str
             for v in sdk_versions:
                 try:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants