From ac7bcfdf7c798d153ba1b16c59f486c200590e48 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Wed, 6 Jul 2022 15:34:09 -0600 Subject: [PATCH 1/4] empty PR to test cmark changes --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b7d5c837fe46..7283b327c0ca 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ compiler crashes. 2. Specify the local toolchain for Xcode's use via `Xcode->Toolchains`. + ### Build Failures Try the suggestions in From e5c8c22b526fc2aa71e79dda08ee3c9cfb968cc3 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Thu, 7 Jul 2022 17:11:10 -0600 Subject: [PATCH 2/4] tell CTest to print on failure for cmark tests --- .../swift_build_support/products/cmake_product.py | 4 ++-- .../swift_build_support/products/cmark.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/swift_build_support/swift_build_support/products/cmake_product.py b/utils/swift_build_support/swift_build_support/products/cmake_product.py index 6e4e63307863..9d29e3f63a35 100644 --- a/utils/swift_build_support/swift_build_support/products/cmake_product.py +++ b/utils/swift_build_support/swift_build_support/products/cmake_product.py @@ -85,7 +85,7 @@ def build_with_cmake(self, build_targets, build_type, build_args, + build_args + build_targets) def test_with_cmake(self, executable_target, results_targets, - build_type, build_args): + build_type, build_args, test_env=None): assert self.toolchain.cmake is not None cmake_build = [] @@ -117,7 +117,7 @@ def target_flag(target): if test_target.startswith("check-swift") and self.args.test_paths: test_target = test_target + "-custom" - shell.call(cmake_build + target_flag(test_target)) + shell.call(cmake_build + target_flag(test_target), env=test_env) print("--- %s finished ---" % target) diff --git a/utils/swift_build_support/swift_build_support/products/cmark.py b/utils/swift_build_support/swift_build_support/products/cmark.py index bde199b37e0d..7d51e276d8db 100644 --- a/utils/swift_build_support/swift_build_support/products/cmark.py +++ b/utils/swift_build_support/swift_build_support/products/cmark.py @@ -94,8 +94,12 @@ def test(self, host_target): # Xcode generator uses "RUN_TESTS" instead of "test". results_targets = ['RUN_TESTS'] + test_env = { + "CTEST_OUTPUT_ON_FAILURE": "ON" + } + self.test_with_cmake(executable_target, results_targets, - self.args.cmark_build_variant, []) + self.args.cmark_build_variant, [], test_env=test_env) def should_install(self, host_target): """should_install() -> Bool From 3b4b2debbec3d863b3de097cc61000ac7f96dc35 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 8 Jul 2022 11:03:32 -0600 Subject: [PATCH 3/4] push the test environment instead of using it as a parameter --- .../swift_build_support/products/cmake_product.py | 4 ++-- .../swift_build_support/products/cmark.py | 6 ++++-- .../swift_build_support/shell.py | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/utils/swift_build_support/swift_build_support/products/cmake_product.py b/utils/swift_build_support/swift_build_support/products/cmake_product.py index 9d29e3f63a35..6e4e63307863 100644 --- a/utils/swift_build_support/swift_build_support/products/cmake_product.py +++ b/utils/swift_build_support/swift_build_support/products/cmake_product.py @@ -85,7 +85,7 @@ def build_with_cmake(self, build_targets, build_type, build_args, + build_args + build_targets) def test_with_cmake(self, executable_target, results_targets, - build_type, build_args, test_env=None): + build_type, build_args): assert self.toolchain.cmake is not None cmake_build = [] @@ -117,7 +117,7 @@ def target_flag(target): if test_target.startswith("check-swift") and self.args.test_paths: test_target = test_target + "-custom" - shell.call(cmake_build + target_flag(test_target), env=test_env) + shell.call(cmake_build + target_flag(test_target)) print("--- %s finished ---" % target) diff --git a/utils/swift_build_support/swift_build_support/products/cmark.py b/utils/swift_build_support/swift_build_support/products/cmark.py index 7d51e276d8db..1408a7462a98 100644 --- a/utils/swift_build_support/swift_build_support/products/cmark.py +++ b/utils/swift_build_support/swift_build_support/products/cmark.py @@ -12,6 +12,7 @@ from . import cmake_product from . import earlyswiftdriver +from .. import shell class CMark(cmake_product.CMakeProduct): @@ -98,8 +99,9 @@ def test(self, host_target): "CTEST_OUTPUT_ON_FAILURE": "ON" } - self.test_with_cmake(executable_target, results_targets, - self.args.cmark_build_variant, [], test_env=test_env) + with shell.pushenv(test_env): + self.test_with_cmake(executable_target, results_targets, + self.args.cmark_build_variant, []) def should_install(self, host_target): """should_install() -> Bool diff --git a/utils/swift_build_support/swift_build_support/shell.py b/utils/swift_build_support/swift_build_support/shell.py index 222d540dd2c9..043402288d88 100644 --- a/utils/swift_build_support/swift_build_support/shell.py +++ b/utils/swift_build_support/swift_build_support/shell.py @@ -162,6 +162,20 @@ def pushd(path, dry_run=None, echo=True): if not dry_run: os.chdir(old_dir) +@contextmanager +def pushenv(env, dry_run=None, echo=True): + for name in env.keys(): + if dry_run or echo: + _echo_command(dry_run, ['export', name + '=' + env[name]]) + if not dry_run: + os.environ[name] = env[name] + yield + for name in env.keys(): + if dry_run or echo: + _echo_command(dry_run, ['unset', name]) + if not dry_run: + del os.environ[key] + def makedirs(path, dry_run=None, echo=True): dry_run = _coerce_dry_run(dry_run) From 6c2676661a8d34ed6b7eb07ada7b366141a3d893 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 8 Jul 2022 11:09:32 -0600 Subject: [PATCH 4/4] restore old environment if it existed previously --- .../swift_build_support/shell.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/utils/swift_build_support/swift_build_support/shell.py b/utils/swift_build_support/swift_build_support/shell.py index 043402288d88..1198b8b23002 100644 --- a/utils/swift_build_support/swift_build_support/shell.py +++ b/utils/swift_build_support/swift_build_support/shell.py @@ -164,17 +164,26 @@ def pushd(path, dry_run=None, echo=True): @contextmanager def pushenv(env, dry_run=None, echo=True): + saved_env = {} for name in env.keys(): if dry_run or echo: _echo_command(dry_run, ['export', name + '=' + env[name]]) if not dry_run: + if name in os.environ: + saved_env[name] = os.environ[name] os.environ[name] = env[name] yield for name in env.keys(): - if dry_run or echo: - _echo_command(dry_run, ['unset', name]) - if not dry_run: - del os.environ[key] + if name in saved_env: + if dry_run or echo: + _echo_command(dry_run, ['export', name + '=' + saved_env[name]]) + if not dry_run: + os.environ[name] = saved_env[name] + else: + if dry_run or echo: + _echo_command(dry_run, ['unset', name]) + if not dry_run: + del os.environ[name] def makedirs(path, dry_run=None, echo=True):