]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix running tests on macOS (#756)
authorNicholas Hutchinson <nshutchinson@gmail.com>
Mon, 28 Dec 2020 14:25:12 +0000 (14:25 +0000)
committerGitHub <noreply@github.com>
Mon, 28 Dec 2020 14:25:12 +0000 (15:25 +0100)
Bash tests were not actually being run on the macOS CI agents because
the version of sed installed there does not understand the `-r` flag:

    sed: illegal option -- r
    usage: sed script [-Ealn] [-i extension] [file ...]
           sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

- use `sed -E` instead of `sed -r` as the latter isn't supported by BSD sed.

- export `SDKROOT` in `test/run`. Otherwise it appears at least some
  some Apple toolchains (e.g. Xcode 10.3) will pick the _latest_ SDK
  installed on the host (e.g.
  `/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk`)
  instead of using the SDK bundled with the toolchain (e.g.
  `/Applications/Xcode_10.3.app/.../MacOSX10.14.sdk`).

  The 10.15 SDK is not compatible with Xcode 10.3:

    ld: unsupported tapi file type '!tapi-tbd' in YAML file
    '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd'
    for architecture x86_64
    clang: error: linker command failed with exit code 1

misc/format-files
test/run
test/suites/base.bash
test/suites/cache_levels.bash

index 1c0405b1903de5cf8ca3f31aa9d833ea9cdb3a34..111705ada475a4a4d0d35bad44336c2b69613420 100755 (executable)
@@ -46,7 +46,7 @@ for file in "$@"; do
         echo "Error: $file not formatted with Clang-Format"
         echo 'Run "make format" or apply this diff:'
         git diff $cf_color --no-index "$file" "$tmp_file" \
-            | sed -r -e "s!^---.*!--- a/$file!" \
+            | sed -E -e "s!^---.*!--- a/$file!" \
                      -e "s!^\+\+\+.*!+++ b/$file!" \
                      -e "/diff --/d" -e "/index /d" \
                      -e "s/.[0-9]*.clang-format.tmp//"
index 9623e49df325185b9c433de32ab720de921adff8..9005dc97b530f89121d5531948c05a53aadcfcee 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -485,6 +485,7 @@ if $HOST_OS_APPLE; then
         echo "Error: xcrun --show-sdk-path failure"
         exit 1
     fi
+    export SDKROOT
 
     SYSROOT="-isysroot `echo \"$SDKROOT\" | sed 's/ /\\ /g'`"
 else
@@ -493,7 +494,7 @@ fi
 
 # ---------------------------------------
 
-all_suites="$(sed -rn 's/^addtest\((.*)\)$/\1/p' $(dirname $0)/CMakeLists.txt)"
+all_suites="$(sed -En 's/^addtest\((.*)\)$/\1/p' $(dirname $0)/CMakeLists.txt)"
 
 for suite in $all_suites; do
     . $(dirname $0)/suites/$suite.bash
index 75e2768f9b8130a9fca267a0af18b405de556acf..30c1c41f41346c4c07c2c01f36e7a68cc7fe10a9 100644 (file)
@@ -788,7 +788,7 @@ EOF
     chmod +x gcc
 
     CCACHE_DEBUG=1 $CCACHE ./gcc -c test1.c
-    compiler_type=$(sed -rn 's/.*Compiler type: (.*)/\1/p' test1.o.ccache-log)
+    compiler_type=$(sed -En 's/.*Compiler type: (.*)/\1/p' test1.o.ccache-log)
     if [ "$compiler_type" != gcc ]; then
         test_failed "Compiler type $compiler_type != gcc"
     fi
@@ -796,7 +796,7 @@ EOF
     rm test1.o.ccache-log
 
     CCACHE_COMPILERTYPE=clang CCACHE_DEBUG=1 $CCACHE ./gcc -c test1.c
-    compiler_type=$(sed -rn 's/.*Compiler type: (.*)/\1/p' test1.o.ccache-log)
+    compiler_type=$(sed -En 's/.*Compiler type: (.*)/\1/p' test1.o.ccache-log)
     if [ "$compiler_type" != clang ]; then
         test_failed "Compiler type $compiler_type != clang"
     fi
index 776508bf8a8d2bc8e745dee3fe257424c5c15c39..ef2e8d57672a71ef49b5ca4f8ecef5999660ce6e 100644 (file)
@@ -11,7 +11,7 @@ expect_on_level() {
     local expected_level="$2"
 
     slashes=$(find $CCACHE_DIR -name "*$type" \
-                  | sed -r -e 's!.*\.ccache/!!' -e 's![^/]*$!!' -e 's![^/]!!g')
+                  | sed -E -e 's!.*\.ccache/!!' -e 's![^/]*$!!' -e 's![^/]!!g')
     actual_level=$(echo -n "$slashes" | wc -c)
     if [ "$actual_level" -ne "$expected_level" ]; then
         test_failed "$type file on level $actual_level, expected level $expected_level"