Files
llvm-project/lldb/test/API/lang/cpp/template-alias/TestTemplateAlias.py
Dave Lee b9225e8607 [lldb] Allow tests to share a single build (#181720)
This changes Python API tests to use a single build shared across all
test functions, instead of the previous default behavior of a separate
build dir for each test function.

This build behavior opt-out, tests can use the previous behavior of one
individual (unshared) build directory per test function, by setting
`SHARED_BUILD_TESTCASE` to False (in the test class).

The motivation is to make the test suite more efficient, by not
repeatedly building the same test source. When running tests on my macOS
machine, this reduces the time of `ninja check-lldb-api` by almost 60%
(sample numbers: from ~492s down to ~207s = 58%). Almost 5min time
saved.

Each test function still calls `self.build()`, but only the first call
will do a build, in the subsequent tests `make` will be a no-op because
the sources won't have changed.
2026-02-18 10:38:45 -08:00

57 lines
2.0 KiB
Python

import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
class TestTemplateAlias(TestBase):
SHARED_BUILD_TESTCASE = False
def do_test(self, extra_flags):
self.build(dictionary=extra_flags)
self.main_source_file = lldb.SBFileSpec("main.cpp")
lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
self.expect_expr("f1", result_type="Foo<int>")
self.expect_expr("f2", result_type="Foo<double>")
self.expect_expr("b1", result_type="Bar<int>")
self.expect_expr("b2", result_type="Bar<double>")
self.expect_expr("bf1", result_type="Bar<int>")
self.expect_expr("bf2", result_type="Bar<double>")
self.expect_expr("bf1", result_type="Bar<int>")
self.expect_expr("bf2", result_type="Bar<double>")
self.expect_expr("cbf1", result_type="Container<int>")
@skipIf(compiler="clang", compiler_version=["<", "21"])
@expectedFailureAll(
bugnumber="LLDB doesn't reconstruct template alias names from template parameters"
)
def test_tag_alias_simple(self):
self.do_test(
dict(CXXFLAGS_EXTRAS="-gdwarf-5 -gtemplate-alias -gsimple-template-names")
)
@skipIf(compiler="clang", compiler_version=["<", "21"])
def test_tag_alias_no_simple(self):
self.do_test(
dict(
CXXFLAGS_EXTRAS="-gdwarf-5 -gtemplate-alias -gno-simple-template-names"
)
)
@skipIf(compiler="clang", compiler_version=["<", "21"])
def test_no_tag_alias_simple(self):
self.do_test(
dict(
CXXFLAGS_EXTRAS="-gdwarf-5 -gno-template-alias -gsimple-template-names"
)
)
@skipIf(compiler="clang", compiler_version=["<", "21"])
def test_no_tag_alias_no_simple(self):
self.do_test(
dict(
CXXFLAGS_EXTRAS="-gdwarf-5 -gno-template-alias -gno-simple-template-names"
)
)