[libcxx-commits] [libcxx] 714644a - [libcxx] [test] Move the is_<platform> functions down to subclasses

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 5 23:10:02 PST 2021


Author: Martin Storsjö
Date: 2021-03-06T08:52:34+02:00
New Revision: 714644a36c3095e1dffeb2fb42da3876a5919d21

URL: https://github.com/llvm/llvm-project/commit/714644a36c3095e1dffeb2fb42da3876a5919d21
DIFF: https://github.com/llvm/llvm-project/commit/714644a36c3095e1dffeb2fb42da3876a5919d21.diff

LOG: [libcxx] [test] Move the is_<platform> functions down to subclasses

If cross testing (and manually specifying a LIBCXX_TARGET_INFO in the
cmake configuration, as the default is to match the build platform),
we want the accessors for querying the target platform, is_windows,
is_darwin, to return the right value depending on which target info
class is used, not based on what platform is running the build and
driving the tests.

When LIBCXX_TARGET_INFO isn't defined, the right target info class
is chosen automatically based on the platform one is running on, so
this shouldn't make any practical difference for such setups.

Differential Revision: https://reviews.llvm.org/D98045

Added: 
    

Modified: 
    libcxx/utils/libcxx/test/target_info.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py
index 9c7a73ba8788..45e3c4ae4d73 100644
--- a/libcxx/utils/libcxx/test/target_info.py
+++ b/libcxx/utils/libcxx/test/target_info.py
@@ -25,13 +25,13 @@ def platform(self):
         return sys.platform.lower().strip()
 
     def is_windows(self):
-        return self.platform() == 'win32'
+        return False
 
     def is_mingw(self):
         return False
 
     def is_darwin(self):
-        return self.platform() == 'darwin'
+        return False
 
     def add_cxx_flags(self, flags): pass
     def add_cxx_compile_flags(self, flags): pass
@@ -53,6 +53,9 @@ class DarwinLocalTI(DefaultTargetInfo):
     def __init__(self, full_config):
         super(DarwinLocalTI, self).__init__(full_config)
 
+    def is_darwin(self):
+        return True
+
     def is_host_macosx(self):
         name = lit.util.to_string(subprocess.check_output(['sw_vers', '-productName'])).strip()
         return name == "Mac OS X"
@@ -187,6 +190,9 @@ class WindowsLocalTI(DefaultTargetInfo):
     def __init__(self, full_config):
         super(WindowsLocalTI, self).__init__(full_config)
 
+    def is_windows(self):
+        return True
+
 class MingwLocalTI(WindowsLocalTI):
     def __init__(self, full_config):
         super(MingwLocalTI, self).__init__(full_config)


        


More information about the libcxx-commits mailing list