mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:34:42 +01:00
[libc++] Consider everything inside %T to be a dependency of each test
Instead of passing file dependencies individually, assume that the
whole content of the unique test directory is a dependency. This
simplifies the test harness significantly, by making %T the directory
that contains everything required to run a test. This also removes the
need for the %{file_dependencies} substitution, which is removed by this
patch.
Furthermore, this patch also changes the harness to execute tests locally
inside %T, so as to avoid creating a separate directory for no purpose.
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
// Test that we can include each header in two TU's and link them together.
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{cxx} -c %s -o %t.first.o %{flags} %{compile_flags}
|
||||
// RUN: %{cxx} -c %s -o %t.second.o -DWITH_MAIN %{flags} %{compile_flags}
|
||||
// RUN: %{cxx} -o %t.exe %t.first.o %t.second.o %{flags} %{link_flags}
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
// GCC doesn't support the aligned-allocation flags.
|
||||
// XFAIL: gcc
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build} -faligned-allocation -fsized-deallocation
|
||||
// RUN: %{run}
|
||||
// RUN: %{build} -faligned-allocation -fno-sized-deallocation -DNO_SIZE
|
||||
|
||||
-1
@@ -8,7 +8,6 @@
|
||||
|
||||
// UNSUPPORTED: -fno-rtti
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.tu1.o -DTU1 -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=1
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.tu2.o -DTU2 -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=1
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.main.o -DMAIN -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=1
|
||||
|
||||
-1
@@ -8,7 +8,6 @@
|
||||
|
||||
// UNSUPPORTED: -fno-rtti
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.tu1.o -DTU1 -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=2
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.tu2.o -DTU2 -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=2
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.main.o -DMAIN -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=2
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# Since we try to pass substitutions as-is to some tests, we must "escape"
|
||||
# them in case they contain other substitutions. Otherwise, the substitutions
|
||||
# will be fully expanded when passed to the tests. For example, we want an
|
||||
# %{exec} substitution that contains `--dependencies %{file_dependencies}`
|
||||
# to be passed as-is, without substituting the file dependencies. This way,
|
||||
# the test itself can use populate %{file_dependencies} as it sees fit, and
|
||||
# %{exec} will respect it.
|
||||
# %{exec} substitution that contains `--execdir %T` to be passed as-is, without
|
||||
# substituting the directory. This way, the test itself can populate %T as it
|
||||
# sees fit, and %{exec} will respect it.
|
||||
#
|
||||
# To solve this problem, we add base64 encoded versions of substitutions just
|
||||
# in this directory. We then base64-decode them from the tests when we need to.
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} %t.exe "HELLO"
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
// Make sure that we provide the %{build} and %{run} convenience substitutions.
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{run} "HELLO"
|
||||
|
||||
|
||||
+6
-5
@@ -1,4 +1,3 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
@@ -7,8 +6,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// FILE_DEPENDENCIES: test.pass.cpp
|
||||
// FILE_DEPENDENCIES: %s
|
||||
// Make sure that FILE_DEPENDENCIES work with relative AND absolute paths.
|
||||
|
||||
// RUN: echo %{file_dependencies} | grep 'test.pass.cpp'
|
||||
// RUN: echo %{file_dependencies} | grep '%s'
|
||||
// FILE_DEPENDENCIES: %S/a.txt
|
||||
// RUN: test -e %T/a.txt
|
||||
|
||||
// FILE_DEPENDENCIES: dir/b.txt
|
||||
// RUN: test -e %T/b.txt
|
||||
@@ -1,13 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Make sure that %{file_dependencies} is empty when no FILE_DEPENDENCIES
|
||||
// line appears. Amongst other things, this makes sure that we don't share
|
||||
// file dependencies across unrelated Lit tests.
|
||||
|
||||
// RUN: test -z "%{file_dependencies}"
|
||||
+1
-1
@@ -9,4 +9,4 @@
|
||||
// Make sure that lit substitutions are expanded inside FILE_DEPENDENCIES lines.
|
||||
|
||||
// FILE_DEPENDENCIES: %s
|
||||
// RUN: echo %{file_dependencies} | grep 'substitute-in-dependencies.sh.cpp'
|
||||
// RUN: test -e %T/substitute-in-dependencies.sh.cpp
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Make sure %{file_dependencies} are substituted properly into RUN commands.
|
||||
|
||||
// FILE_DEPENDENCIES: a.txt
|
||||
// FILE_DEPENDENCIES: b.txt, c.txt
|
||||
// FILE_DEPENDENCIES: /absolute/d.txt
|
||||
// RUN: echo %{file_dependencies} | grep 'a.txt'
|
||||
// RUN: echo %{file_dependencies} | grep 'b.txt'
|
||||
// RUN: echo %{file_dependencies} | grep 'c.txt'
|
||||
// RUN: echo %{file_dependencies} | grep '/absolute/d.txt'
|
||||
@@ -15,7 +15,6 @@
|
||||
// We also check that the path of test-executables is replaced whether they
|
||||
// appear first in the command-line or not.
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe
|
||||
// RUN: %{exec} %t.exe 0
|
||||
// RUN: %{exec} ! %t.exe 1
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// - %{link_flags}
|
||||
// - %{exec}
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe
|
||||
// RUN: %{exec} %t.exe "HELLO"
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
// TODO: We don't enable -Werror on GCC right now, because too many tests fail.
|
||||
// UNSUPPORTED: gcc
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build} -Wunused-variable
|
||||
// RUN: %{run}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
// %{exec}, the one difference we can rely on is that we're in a temporary
|
||||
// directory with all file dependencies satisfied, so that's what we use.
|
||||
|
||||
// FILE_DEPENDENCIES: %t.foobar
|
||||
// RUN: touch %t.foobar
|
||||
// RUN: %{exec} echo \| ls > %t.out
|
||||
// RUN: grep -e ".foobar" %t.out
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
|
||||
// RUN: %{build}
|
||||
// RUN: %{run}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
// Regression test for PR42676.
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{cxx} %{flags} %s -o %t.exe %{compile_flags} %{link_flags} -D_LIBCPP_HIDE_FROM_ABI_PER_TU
|
||||
// RUN: %{run}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
// on Darwin out-of-the-box.
|
||||
// REQUIRES: has-fblocks && darwin
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build} -fblocks
|
||||
// RUN: %{run}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build} -O2
|
||||
// RUN: %{run}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
// istream cerr;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} %t.exe 2> %t.err
|
||||
// RUN: grep -e 'Hello World!' %t.err
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
// istream cin;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} echo "123" \| %t.exe > %t.out
|
||||
// RUN: grep -e 'The number is 123!' %t.out
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
// istream clog;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} %t.exe 2> %t.err
|
||||
// RUN: grep -e 'Hello World!' %t.err
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
// istream cout;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} %t.exe > %t.out
|
||||
// RUN: grep -e 'Hello World!' %t.out
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
// istream wcerr;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} %t.exe 2> %t.err
|
||||
// RUN: grep -e 'Hello World!' %t.err
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
// istream wcin;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} echo "123" \| %t.exe > %t.out
|
||||
// RUN: grep -e 'The number is 123!' %t.out
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
// istream wclog;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} %t.exe 2> %t.err
|
||||
// RUN: grep -e 'Hello World!' %t.err
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
// istream wcout;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{exec} %t.exe > %t.out
|
||||
// RUN: grep -e 'Hello World!' %t.out
|
||||
|
||||
-1
@@ -13,7 +13,6 @@
|
||||
|
||||
// class condition_variable_any;
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build}
|
||||
// RUN: %{run} 1
|
||||
// RUN: %{run} 2
|
||||
|
||||
@@ -747,15 +747,14 @@ class Configuration(object):
|
||||
codesign_ident = self.get_lit_conf('llvm_codesign_identity', '')
|
||||
env_vars = ' '.join('%s=%s' % (k, pipes.quote(v)) for (k, v) in self.exec_env.items())
|
||||
exec_args = [
|
||||
'--execdir %T',
|
||||
'--codesign_identity "{}"'.format(codesign_ident),
|
||||
'--dependencies %{file_dependencies}',
|
||||
'--env {}'.format(env_vars)
|
||||
]
|
||||
if isinstance(self.executor, SSHExecutor):
|
||||
exec_args.append('--host {}'.format(self.executor.user_prefix + self.executor.host))
|
||||
executor = os.path.join(self.libcxx_src_root, 'utils', 'ssh.py')
|
||||
else:
|
||||
exec_args.append('--execdir %t.execdir')
|
||||
executor = os.path.join(self.libcxx_src_root, 'utils', 'run.py')
|
||||
sub.append(('%{exec}', '{} {} {} -- '.format(pipes.quote(sys.executable),
|
||||
pipes.quote(executor),
|
||||
|
||||
@@ -70,9 +70,9 @@ def sourceBuilds(config, source):
|
||||
"mkdir -p %T",
|
||||
"%{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe"
|
||||
]
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands, fileDependencies=['%t.exe'])
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands)
|
||||
out, err, exitCode, timeoutInfo = _executeScriptInternal(test, commands)
|
||||
cleanup = libcxx.test.newformat.parseScript(test, preamble=['rm %t.exe'], fileDependencies=[])
|
||||
cleanup = libcxx.test.newformat.parseScript(test, preamble=['rm %t.exe'])
|
||||
_executeScriptInternal(test, cleanup)
|
||||
return exitCode == 0
|
||||
|
||||
@@ -85,7 +85,7 @@ def hasCompileFlag(config, flag):
|
||||
"""
|
||||
with _makeConfigTest(config) as test:
|
||||
commands = ["%{{cxx}} -xc++ {} -Werror -fsyntax-only %{{flags}} %{{compile_flags}} {}".format(os.devnull, flag)]
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands, fileDependencies=[])
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands)
|
||||
out, err, exitCode, timeoutInfo = _executeScriptInternal(test, commands)
|
||||
return exitCode == 0
|
||||
|
||||
@@ -111,9 +111,9 @@ def hasLocale(config, locale):
|
||||
"%{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe",
|
||||
"%{{exec}} %t.exe {}".format(pipes.quote(locale)),
|
||||
]
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands, fileDependencies=['%t.exe'])
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands)
|
||||
out, err, exitCode, timeoutInfo = _executeScriptInternal(test, commands)
|
||||
cleanup = libcxx.test.newformat.parseScript(test, preamble=['rm %t.exe'], fileDependencies=[])
|
||||
cleanup = libcxx.test.newformat.parseScript(test, preamble=['rm %t.exe'])
|
||||
_executeScriptInternal(test, cleanup)
|
||||
return exitCode == 0
|
||||
|
||||
@@ -129,7 +129,7 @@ def compilerMacros(config, flags=''):
|
||||
"""
|
||||
with _makeConfigTest(config) as test:
|
||||
commands = ["%{{cxx}} -xc++ {} -dM -E %{{flags}} %{{compile_flags}} {}".format(os.devnull, flags)]
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands, fileDependencies=[])
|
||||
commands = libcxx.test.newformat.parseScript(test, preamble=commands)
|
||||
unparsedOutput, err, exitCode, timeoutInfo = _executeScriptInternal(test, commands)
|
||||
parsedMacros = dict()
|
||||
defines = (l.strip() for l in unparsedOutput.split('\n') if l.startswith('#define '))
|
||||
|
||||
@@ -11,6 +11,7 @@ import lit.formats
|
||||
import os
|
||||
import pipes
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
def _supportsVerify(config):
|
||||
@@ -40,7 +41,7 @@ def _getTempPaths(test):
|
||||
tmpBase = os.path.join(tmpDir, 't')
|
||||
return tmpDir, tmpBase
|
||||
|
||||
def parseScript(test, preamble, fileDependencies):
|
||||
def parseScript(test, preamble):
|
||||
"""
|
||||
Extract the script from a test, with substitutions applied.
|
||||
|
||||
@@ -54,9 +55,6 @@ def parseScript(test, preamble, fileDependencies):
|
||||
These commands can contain unexpanded substitutions, but they
|
||||
must not be of the form 'RUN:' -- they must be proper commands
|
||||
once substituted.
|
||||
|
||||
- fileDependencies
|
||||
A list of additional file dependencies for the test.
|
||||
"""
|
||||
|
||||
# Get the default substitutions
|
||||
@@ -71,7 +69,7 @@ def parseScript(test, preamble, fileDependencies):
|
||||
|
||||
# Parse the test file, including custom directives
|
||||
additionalCompileFlags = []
|
||||
fileDependencies = list(fileDependencies)
|
||||
fileDependencies = []
|
||||
parsers = [
|
||||
lit.TestRunner.IntegratedTestKeywordParser('FILE_DEPENDENCIES:',
|
||||
lit.TestRunner.ParserKind.LIST,
|
||||
@@ -81,30 +79,25 @@ def parseScript(test, preamble, fileDependencies):
|
||||
initial_value=additionalCompileFlags)
|
||||
]
|
||||
|
||||
script = list(preamble)
|
||||
parsed = lit.TestRunner.parseIntegratedTestScript(test, additional_parsers=parsers,
|
||||
require_script=not script)
|
||||
if isinstance(parsed, lit.Test.Result):
|
||||
return parsed
|
||||
script += parsed
|
||||
scriptInTest = lit.TestRunner.parseIntegratedTestScript(test, additional_parsers=parsers,
|
||||
require_script=not preamble)
|
||||
if isinstance(scriptInTest, lit.Test.Result):
|
||||
return scriptInTest
|
||||
|
||||
script = []
|
||||
|
||||
# For each file dependency in FILE_DEPENDENCIES, inject a command to copy
|
||||
# that file to the execution directory. Execute the copy from %S to allow
|
||||
# relative paths from the test directory.
|
||||
for dep in fileDependencies:
|
||||
script += ['%dbg(SETUP) cd %S && cp {} %T'.format(dep)]
|
||||
script += preamble
|
||||
script += scriptInTest
|
||||
|
||||
# Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
|
||||
substitutions = [(s, x + ' ' + ' '.join(additionalCompileFlags)) if s == '%{compile_flags}'
|
||||
else (s, x) for (s, x) in substitutions]
|
||||
|
||||
# Perform substitutions inside FILE_DEPENDENCIES lines (or injected dependencies).
|
||||
# This allows using variables like %t in file dependencies. Also note that we really
|
||||
# need to resolve %{file_dependencies} now, because otherwise we won't be able to
|
||||
# make all paths absolute below.
|
||||
fileDependencies = lit.TestRunner.applySubstitutions(fileDependencies, substitutions,
|
||||
recursion_limit=test.config.recursiveExpansionLimit)
|
||||
|
||||
# Add the %{file_dependencies} substitution before we perform substitutions
|
||||
# inside the script.
|
||||
testDir = os.path.dirname(test.getSourcePath())
|
||||
fileDependencies = [f if os.path.isabs(f) else os.path.join(testDir, f) for f in fileDependencies]
|
||||
substitutions.append(('%{file_dependencies}', ' '.join(map(pipes.quote, fileDependencies))))
|
||||
|
||||
# Perform substitutions in the script itself.
|
||||
script = lit.TestRunner.applySubstitutions(script, substitutions,
|
||||
recursion_limit=test.config.recursiveExpansionLimit)
|
||||
@@ -170,11 +163,10 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
|
||||
This directive expresses that the test requires the provided files
|
||||
or directories in order to run. An example is a test that requires
|
||||
some test input stored in a data file. When a test file contains
|
||||
such a directive, this test format will collect them and make them
|
||||
available in a special %{file_dependencies} substitution. The intent
|
||||
is that if one needs to e.g. execute tests on a remote host, the
|
||||
%{exec} substitution could use %{file_dependencies} to know which
|
||||
files and directories to copy to the remote host.
|
||||
such a directive, this test format will collect them and copy them
|
||||
to the directory represented by %T. The intent is that %T contains
|
||||
all the inputs necessary to run the test, such that e.g. execution
|
||||
on a remote host can be done by simply copying %T to the host.
|
||||
|
||||
// ADDITIONAL_COMPILE_FLAGS: flag1, flag2, flag3
|
||||
|
||||
@@ -188,11 +180,6 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
|
||||
==============================================
|
||||
The test format will define the following substitutions for use inside tests:
|
||||
|
||||
%{file_dependencies}
|
||||
|
||||
Expands to the list of files that this test depends on.
|
||||
See FILE_DEPENDENCIES above.
|
||||
|
||||
%{build}
|
||||
Expands to a command-line that builds the current source
|
||||
file with the %{flags}, %{compile_flags} and %{link_flags}
|
||||
@@ -273,7 +260,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
|
||||
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe",
|
||||
"%dbg(EXECUTED AS) %{exec} ! %t.exe"
|
||||
]
|
||||
return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
|
||||
return self._executeShTest(test, litConfig, steps)
|
||||
elif filename.endswith('.verify.cpp'):
|
||||
if not supportsVerify:
|
||||
return lit.Test.Result(lit.Test.UNSUPPORTED,
|
||||
@@ -291,7 +278,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
|
||||
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe",
|
||||
"%dbg(EXECUTED AS) %{exec} %t.exe"
|
||||
]
|
||||
return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
|
||||
return self._executeShTest(test, litConfig, steps)
|
||||
# This is like a .verify.cpp test when clang-verify is supported,
|
||||
# otherwise it's like a .compile.fail.cpp test. This is only provided
|
||||
# for backwards compatibility with the test suite.
|
||||
@@ -313,11 +300,11 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
|
||||
string = ' '.join(flags)
|
||||
config.substitutions = [(s, x + ' ' + string) if s == '%{compile_flags}' else (s, x) for (s, x) in config.substitutions]
|
||||
|
||||
def _executeShTest(self, test, litConfig, steps, fileDependencies=None):
|
||||
def _executeShTest(self, test, litConfig, steps):
|
||||
if test.config.unsupported:
|
||||
return lit.Test.Result(lit.Test.UNSUPPORTED, 'Test is unsupported')
|
||||
|
||||
script = parseScript(test, steps, fileDependencies or [])
|
||||
script = parseScript(test, steps)
|
||||
if isinstance(script, lit.Test.Result):
|
||||
return script
|
||||
|
||||
|
||||
+2
-21
@@ -13,8 +13,6 @@ program's error code.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@@ -23,7 +21,6 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--execdir', type=str, required=True)
|
||||
parser.add_argument('--codesign_identity', type=str, required=False, default=None)
|
||||
parser.add_argument('--dependencies', type=str, nargs='*', required=False, default=[])
|
||||
parser.add_argument('--env', type=str, nargs='*', required=False, default=dict())
|
||||
(args, remaining) = parser.parse_known_args(sys.argv[1:])
|
||||
|
||||
@@ -43,24 +40,8 @@ def main():
|
||||
# Extract environment variables into a dictionary
|
||||
env = {k : v for (k, v) in map(lambda s: s.split('=', 1), args.env)}
|
||||
|
||||
# Create the execution directory, and make sure we remove it at the end.
|
||||
try:
|
||||
os.makedirs(args.execdir)
|
||||
|
||||
# Ensure the file dependencies exist and copy them to the execution directory.
|
||||
for dep in args.dependencies:
|
||||
if not os.path.exists(dep):
|
||||
sys.stderr.write('Missing file or directory "{}" marked as a dependency of a test'.format(dep))
|
||||
exit(1)
|
||||
if os.path.isdir(dep):
|
||||
shutil.copytree(dep, os.path.join(args.execdir, os.path.basename(dep)), symlinks=True)
|
||||
else:
|
||||
shutil.copy2(dep, args.execdir)
|
||||
|
||||
# Run the command line with the given environment in the execution directory.
|
||||
return subprocess.call(subprocess.list2cmdline(commandLine), cwd=args.execdir, env=env, shell=True)
|
||||
finally:
|
||||
shutil.rmtree(args.execdir)
|
||||
# Run the command line with the given environment in the execution directory.
|
||||
return subprocess.call(subprocess.list2cmdline(commandLine), cwd=args.execdir, env=env, shell=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+7
-11
@@ -25,8 +25,8 @@ import tempfile
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--host', type=str, required=True)
|
||||
parser.add_argument('--execdir', type=str, required=True)
|
||||
parser.add_argument('--codesign_identity', type=str, required=False, default=None)
|
||||
parser.add_argument('--dependencies', type=str, nargs='*', required=False, default=[])
|
||||
parser.add_argument('--env', type=str, nargs='*', required=False, default=dict())
|
||||
(args, remaining) = parser.parse_known_args(sys.argv[1:])
|
||||
|
||||
@@ -40,6 +40,7 @@ def main():
|
||||
scp = lambda src, dst: ['scp', '-q', '-oBatchMode=yes', src, '{}:{}'.format(args.host, dst)]
|
||||
|
||||
# Create a temporary directory where the test will be run.
|
||||
# That is effectively the value of %T on the remote host.
|
||||
tmp = subprocess.check_output(ssh('mktemp -d /tmp/libcxx.XXXXXXXXXX'), universal_newlines=True).strip()
|
||||
|
||||
# HACK:
|
||||
@@ -58,16 +59,12 @@ def main():
|
||||
for exe in filter(isTestExe, commandLine):
|
||||
subprocess.check_call(['xcrun', 'codesign', '-f', '-s', args.codesign_identity, exe], env={})
|
||||
|
||||
# Ensure the test dependencies exist, tar them up and copy the tarball
|
||||
# over to the remote host.
|
||||
# tar up the execution directory (which contains everything that's needed
|
||||
# to run the test), and copy the tarball over to the remote host.
|
||||
try:
|
||||
tmpTar = tempfile.NamedTemporaryFile(suffix='.tar', delete=False)
|
||||
with tarfile.open(fileobj=tmpTar, mode='w') as tarball:
|
||||
for dep in args.dependencies:
|
||||
if not os.path.exists(dep):
|
||||
sys.stderr.write('Missing file or directory "{}" marked as a dependency of a test'.format(dep))
|
||||
return 1
|
||||
tarball.add(dep, arcname=os.path.basename(dep))
|
||||
tarball.add(args.execdir, arcname=os.path.basename(args.execdir))
|
||||
|
||||
# Make sure we close the file before we scp it, because accessing
|
||||
# the temporary file while still open doesn't work on Windows.
|
||||
@@ -82,7 +79,7 @@ def main():
|
||||
|
||||
# Untar the dependencies in the temporary directory and remove the tarball.
|
||||
remoteCommands = [
|
||||
'tar -xf {} -C {}'.format(remoteTarball, tmp),
|
||||
'tar -xf {} -C {} --strip-components 1'.format(remoteTarball, tmp),
|
||||
'rm {}'.format(remoteTarball)
|
||||
]
|
||||
|
||||
@@ -95,8 +92,7 @@ def main():
|
||||
# Execute the command through SSH in the temporary directory, with the
|
||||
# correct environment. We tweak the command line to run it on the remote
|
||||
# host by transforming the path of test-executables to their path in the
|
||||
# temporary directory, where we know they have been copied when we handled
|
||||
# test dependencies above.
|
||||
# temporary directory on the remote host.
|
||||
commandLine = (pathOnRemote(x) if isTestExe(x) else x for x in commandLine)
|
||||
remoteCommands.append('cd {}'.format(tmp))
|
||||
if args.env:
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
// in the system libc++abi installation on OS X. (DYLD_LIBRARY_PATH is ignored
|
||||
// for shell tests because of Apple security features).
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{cxx} %{flags} %{compile_flags} -Wno-unreachable-code -c %s -o %t.one.o
|
||||
// RUN: %{cxx} %{flags} %{compile_flags} -Wno-unreachable-code -c %s -o %t.two.o -DTU_ONE
|
||||
// RUN: %{cxx} %{flags} %t.one.o %t.two.o %{link_libcxxabi} %{link_flags} -o %t.exe
|
||||
|
||||
Reference in New Issue
Block a user