[test] Add support for Objective-C++ tests
Differential revision: https://reviews.llvm.org/D33049 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303466 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
13
test/libcxx/selftest/test.arc.fail.mm
Normal file
13
test/libcxx/selftest/test.arc.fail.mm
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#if __has_feature(objc_arc)
|
||||||
|
#error This test should not compile.
|
||||||
|
#endif
|
||||||
17
test/libcxx/selftest/test.arc.pass.mm
Normal file
17
test/libcxx/selftest/test.arc.pass.mm
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#if __has_feature(objc_arc) == 0
|
||||||
|
#error "arc should be enabled"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
}
|
||||||
13
test/libcxx/selftest/test.fail.mm
Normal file
13
test/libcxx/selftest/test.fail.mm
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#if __has_feature(objc_arc) == 0
|
||||||
|
#error This test should not compile.
|
||||||
|
#endif
|
||||||
17
test/libcxx/selftest/test.pass.mm
Normal file
17
test/libcxx/selftest/test.pass.mm
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#if __has_feature(objc_arc)
|
||||||
|
#error "arc should *not* be enabled"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ class CXXCompiler(object):
|
|||||||
modules_flags=None, use_modules=False,
|
modules_flags=None, use_modules=False,
|
||||||
use_ccache=False, use_warnings=False, compile_env=None,
|
use_ccache=False, use_warnings=False, compile_env=None,
|
||||||
cxx_type=None, cxx_version=None):
|
cxx_type=None, cxx_version=None):
|
||||||
|
self.source_lang = 'c++'
|
||||||
self.path = path
|
self.path = path
|
||||||
self.flags = list(flags or [])
|
self.flags = list(flags or [])
|
||||||
self.compile_flags = list(compile_flags or [])
|
self.compile_flags = list(compile_flags or [])
|
||||||
@@ -108,7 +109,7 @@ class CXXCompiler(object):
|
|||||||
if out is not None:
|
if out is not None:
|
||||||
cmd += ['-o', out]
|
cmd += ['-o', out]
|
||||||
if input_is_cxx:
|
if input_is_cxx:
|
||||||
cmd += ['-x', 'c++']
|
cmd += ['-x', self.source_lang]
|
||||||
if isinstance(source_files, list):
|
if isinstance(source_files, list):
|
||||||
cmd += source_files
|
cmd += source_files
|
||||||
elif isinstance(source_files, str):
|
elif isinstance(source_files, str):
|
||||||
|
|||||||
@@ -466,6 +466,12 @@ class Configuration(object):
|
|||||||
self.config.available_features.add('glibc-%s' % maj_v)
|
self.config.available_features.add('glibc-%s' % maj_v)
|
||||||
self.config.available_features.add('glibc-%s.%s' % (maj_v, min_v))
|
self.config.available_features.add('glibc-%s.%s' % (maj_v, min_v))
|
||||||
|
|
||||||
|
# Support Objective-C++ only on MacOS and if the compiler supports it.
|
||||||
|
if self.target_info.platform() == "darwin" and \
|
||||||
|
self.target_info.is_host_macosx() and \
|
||||||
|
self.cxx.hasCompileFlag(["-x", "objective-c++", "-fobjc-arc"]):
|
||||||
|
self.config.available_features.add("objective-c++")
|
||||||
|
|
||||||
def configure_compile_flags(self):
|
def configure_compile_flags(self):
|
||||||
no_default_flags = self.get_lit_bool('no_default_flags', False)
|
no_default_flags = self.get_lit_bool('no_default_flags', False)
|
||||||
if not no_default_flags:
|
if not no_default_flags:
|
||||||
|
|||||||
@@ -87,14 +87,22 @@ class LibcxxTestFormat(object):
|
|||||||
name_root, name_ext = os.path.splitext(name)
|
name_root, name_ext = os.path.splitext(name)
|
||||||
is_libcxx_test = test.path_in_suite[0] == 'libcxx'
|
is_libcxx_test = test.path_in_suite[0] == 'libcxx'
|
||||||
is_sh_test = name_root.endswith('.sh')
|
is_sh_test = name_root.endswith('.sh')
|
||||||
is_pass_test = name.endswith('.pass.cpp')
|
is_pass_test = name.endswith('.pass.cpp') or name.endswith('.pass.mm')
|
||||||
is_fail_test = name.endswith('.fail.cpp')
|
is_fail_test = name.endswith('.fail.cpp') or name.endswith('.fail.mm')
|
||||||
assert is_sh_test or name_ext == '.cpp', 'non-cpp file must be sh test'
|
is_objcxx_test = name.endswith('.mm')
|
||||||
|
is_objcxx_arc_test = name.endswith('.arc.pass.mm') or \
|
||||||
|
name.endswith('.arc.fail.mm')
|
||||||
|
assert is_sh_test or name_ext == '.cpp' or name_ext == '.mm', \
|
||||||
|
'non-cpp file must be sh test'
|
||||||
|
|
||||||
if test.config.unsupported:
|
if test.config.unsupported:
|
||||||
return (lit.Test.UNSUPPORTED,
|
return (lit.Test.UNSUPPORTED,
|
||||||
"A lit.local.cfg marked this unsupported")
|
"A lit.local.cfg marked this unsupported")
|
||||||
|
|
||||||
|
if is_objcxx_test and not \
|
||||||
|
'objective-c++' in test.config.available_features:
|
||||||
|
return (lit.Test.UNSUPPORTED, "Objective-C++ is not supported")
|
||||||
|
|
||||||
parsers = self._make_custom_parsers()
|
parsers = self._make_custom_parsers()
|
||||||
script = lit.TestRunner.parseIntegratedTestScript(
|
script = lit.TestRunner.parseIntegratedTestScript(
|
||||||
test, additional_parsers=parsers, require_script=is_sh_test)
|
test, additional_parsers=parsers, require_script=is_sh_test)
|
||||||
@@ -133,6 +141,14 @@ class LibcxxTestFormat(object):
|
|||||||
if '#define _LIBCPP_ASSERT' in contents:
|
if '#define _LIBCPP_ASSERT' in contents:
|
||||||
test_cxx.useModules(False)
|
test_cxx.useModules(False)
|
||||||
|
|
||||||
|
if is_objcxx_test:
|
||||||
|
test_cxx.source_lang = 'objective-c++'
|
||||||
|
if is_objcxx_arc_test:
|
||||||
|
test_cxx.compile_flags += ['-fobjc-arc']
|
||||||
|
else:
|
||||||
|
test_cxx.compile_flags += ['-fno-objc-arc']
|
||||||
|
test_cxx.link_flags += ['-framework', 'Foundation']
|
||||||
|
|
||||||
# Dispatch the test based on its suffix.
|
# Dispatch the test based on its suffix.
|
||||||
if is_sh_test:
|
if is_sh_test:
|
||||||
if not isinstance(self.executor, LocalExecutor):
|
if not isinstance(self.executor, LocalExecutor):
|
||||||
|
|||||||
Reference in New Issue
Block a user