Skip to content

[libc++][WIP] Move the libc++ test format to Lit #90803

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/test/configs/cmake-bridge.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import libcxx.test.format
# Basic configuration of the test suite
config.name = os.path.basename('@LIBCXX_TEST_CONFIG@')
config.test_source_root = os.path.join('@LIBCXX_SOURCE_DIR@', 'test')
config.test_format = libcxx.test.format.CxxStandardLibraryTest()
config.test_format = libcxx.test.format.LibcxxTest()
config.recursiveExpansionLimit = 10
config.test_exec_root = os.path.join('@CMAKE_BINARY_DIR@', 'test')

Expand Down
15 changes: 2 additions & 13 deletions libcxx/utils/libcxx/test/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,7 @@
# ===----------------------------------------------------------------------===##

import os


def _getSubstitution(substitution, config):
for (orig, replacement) in config.substitutions:
if orig == substitution:
return replacement
raise ValueError("Substitution {} is not in the config.".format(substitution))


def _appendToSubstitution(substitutions, key, value):
return [(k, v + " " + value) if k == key else (k, v) for (k, v) in substitutions]

import lit.formats

def configure(parameters, features, config, lit_config):
note = lambda s: lit_config.note("({}) {}".format(config.name, s))
Expand Down Expand Up @@ -53,7 +42,7 @@ def configure(parameters, features, config, lit_config):

# Print the basic substitutions
for sub in ("%{cxx}", "%{flags}", "%{compile_flags}", "%{link_flags}", "%{exec}"):
note("Using {} substitution: '{}'".format(sub, _getSubstitution(sub, config)))
note("Using {} substitution: '{}'".format(sub, lit.formats.standardlibrarytest._getSubstitution(sub, config)))

# Print all available features
note("All available features: {}".format(", ".join(sorted(config.available_features))))
32 changes: 10 additions & 22 deletions libcxx/utils/libcxx/test/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import shutil
import tempfile

import libcxx.test.format
import lit
import lit.formats
import lit.LitConfig
import lit.Test
import lit.TestRunner
Expand Down Expand Up @@ -99,7 +99,7 @@ def _executeWithFakeConfig(test, commands):
order="smart",
params={},
)
return libcxx.test.format._executeScriptInternal(test, litConfig, commands)
return lit.formats.standardlibrarytest._executeScriptInternal(test, litConfig, commands)


def _makeConfigTest(config):
Expand All @@ -121,12 +121,12 @@ def _makeConfigTest(config):

class TestWrapper(lit.Test.Test):
def __enter__(self):
testDir, _ = libcxx.test.format._getTempPaths(self)
testDir, _ = lit.formats.standardlibrarytest._getTempPaths(self)
os.makedirs(testDir)
return self

def __exit__(self, *args):
testDir, _ = libcxx.test.format._getTempPaths(self)
testDir, _ = lit.formats.standardlibrarytest._getTempPaths(self)
shutil.rmtree(testDir)
os.remove(tmp.name)

Expand Down Expand Up @@ -348,18 +348,6 @@ def featureTestMacros(config, flags=""):
}


def _getSubstitution(substitution, config):
for (orig, replacement) in config.substitutions:
if orig == substitution:
return replacement
raise ValueError('Substitution {} is not in the config.'.format(substitution))

def _appendToSubstitution(substitutions, key, value):
return [(k, v + " " + value) if k == key else (k, v) for (k, v) in substitutions]

def _prependToSubstitution(substitutions, key, value):
return [(k, value + " " + v) if k == key else (k, v) for (k, v) in substitutions]

def _ensureFlagIsSupported(config, flag):
(exitCode, out, err) = tryCompileFlag(config, flag)
assert (
Expand Down Expand Up @@ -442,7 +430,7 @@ def __init__(self, flag):
def applyTo(self, config):
flag = self._getFlag(config)
_ensureFlagIsSupported(config, flag)
config.substitutions = _appendToSubstitution(
config.substitutions = lit.formats.standardlibrarytest._appendToSubstitution(
config.substitutions, "%{flags}", flag
)

Expand All @@ -464,7 +452,7 @@ def __init__(self, flag):
def applyTo(self, config):
flag = self._getFlag(config)
if hasCompileFlag(config, flag):
config.substitutions = _appendToSubstitution(
config.substitutions = lit.formats.standardlibrarytest._appendToSubstitution(
config.substitutions, "%{flags}", flag
)

Expand All @@ -486,7 +474,7 @@ def __init__(self, flag):
def applyTo(self, config):
flag = self._getFlag(config)
_ensureFlagIsSupported(config, flag)
config.substitutions = _appendToSubstitution(
config.substitutions = lit.formats.standardlibrarytest._appendToSubstitution(
config.substitutions, "%{compile_flags}", flag
)

Expand All @@ -508,7 +496,7 @@ def __init__(self, flag):
def applyTo(self, config):
flag = self._getFlag(config)
_ensureFlagIsSupported(config, flag)
config.substitutions = _appendToSubstitution(
config.substitutions = lit.formats.standardlibrarytest._appendToSubstitution(
config.substitutions, "%{link_flags}", flag
)

Expand All @@ -530,7 +518,7 @@ def __init__(self, flag):
def applyTo(self, config):
flag = self._getFlag(config)
_ensureFlagIsSupported(config, flag)
config.substitutions = _prependToSubstitution(
config.substitutions = lit.formats.standardlibrarytest._prependToSubstitution(
config.substitutions, "%{link_flags}", flag
)

Expand All @@ -554,7 +542,7 @@ def applyTo(self, config):
flag = self._getFlag(config)
# Use -Werror to make sure we see an error about the flag being unsupported.
if hasCompileFlag(config, "-Werror " + flag):
config.substitutions = _appendToSubstitution(
config.substitutions = lit.formats.standardlibrarytest._appendToSubstitution(
config.substitutions, "%{compile_flags}", flag
)

Expand Down
Loading
Loading