[clang] ccabe93 - clang: Make tests using symlinks more consistent.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 5 09:57:20 PDT 2020


Author: Nico Weber
Date: 2020-04-05T12:56:41-04:00
New Revision: ccabe9329857141e0b676951ff89092d7f88bed0

URL: https://github.com/llvm/llvm-project/commit/ccabe9329857141e0b676951ff89092d7f88bed0
DIFF: https://github.com/llvm/llvm-project/commit/ccabe9329857141e0b676951ff89092d7f88bed0.diff

LOG: clang: Make tests using symlinks more consistent.

Instead of checking if each symlink exists before removing it,
remove the whole temp dir housing the symlinks before recreating it.
This is a bit shorter, conceptually simpler (in that the first
and consecutive test runs have more similar behavior), it's what we're
already doing in almost all places where we do it, and it works if the
symlink exists but is a dead link (e.g. when it points into the build
dir but the build dir is renamed).

No intended behavior change.

Added: 
    

Modified: 
    clang/test/Driver/config-file3.c
    clang/test/Driver/mingw-sysroot.cpp
    clang/test/Driver/riscv32-toolchain-extra.c
    clang/test/Driver/riscv64-toolchain-extra.c
    clang/test/Driver/target-override.c

Removed: 
    


################################################################################
diff  --git a/clang/test/Driver/config-file3.c b/clang/test/Driver/config-file3.c
index 938411cf0fff..148646c2ebbf 100644
--- a/clang/test/Driver/config-file3.c
+++ b/clang/test/Driver/config-file3.c
@@ -16,8 +16,8 @@
 
 //--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
 //
+// RUN: rm -rf %T/testdmode
 // RUN: mkdir -p %T/testdmode
-// RUN: [ ! -s %T/testdmode/qqq-clang-g++ ] || rm %T/testdmode/qqq-clang-g++
 // RUN: ln -s %clang %T/testdmode/qqq-clang-g++
 // RUN: echo "-Wundefined-func-template" > %T/testdmode/qqq-clang-g++.cfg
 // RUN: echo "-Werror" > %T/testdmode/qqq.cfg
@@ -53,8 +53,8 @@
 
 //--- Config files are searched for in binary directory as well.
 //
+// RUN: rm -rf %T/testbin
 // RUN: mkdir -p %T/testbin
-// RUN: [ ! -s %T/testbin/clang ] || rm %T/testbin/clang
 // RUN: ln -s %clang %T/testbin/clang
 // RUN: echo "-Werror" > %T/testbin/aaa.cfg
 // RUN: %T/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN
@@ -68,8 +68,8 @@
 
 //--- When reloading config file, x86_64-clang-g++ tries to find config i386-clang-g++.cfg first.
 //
+// RUN: rm -rf %T/testreload
 // RUN: mkdir -p %T/testreload
-// RUN: [ ! -s %T/testreload/x86_64-clang-g++ ] || rm %T/testreload/x86_64-clang-g++
 // RUN: ln -s %clang %T/testreload/x86_64-clang-g++
 // RUN: echo "-Wundefined-func-template" > %T/testreload/i386-clang-g++.cfg
 // RUN: echo "-Werror" > %T/testreload/i386.cfg

diff  --git a/clang/test/Driver/mingw-sysroot.cpp b/clang/test/Driver/mingw-sysroot.cpp
index d477f314195f..9c6ded76127d 100644
--- a/clang/test/Driver/mingw-sysroot.cpp
+++ b/clang/test/Driver/mingw-sysroot.cpp
@@ -1,19 +1,15 @@
 // REQUIRES: shell
 // UNSUPPORTED: system-windows
 
+// RUN: rm -rf %T/testroot-gcc/bin
 // RUN: mkdir -p %T/testroot-gcc/bin
-// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc ] || rm %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
-// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-clang ] || rm %T/testroot-gcc/bin/x86_64-w64-mingw32-clang
-// RUN: [ ! -s %T/testroot-gcc/x86_64-w64-mingw32 ] || rm %T/testroot-gcc/x86_64-w64-mingw32
-// RUN: [ ! -s %T/testroot-gcc/lib ] || rm %T/testroot-gcc/lib
 // RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
 // RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-clang
 // RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %T/testroot-gcc/x86_64-w64-mingw32
 // RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/lib %T/testroot-gcc/lib
 
+// RUN: rm -rf %T/testroot-clang/bin
 // RUN: mkdir -p %T/testroot-clang/bin
-// RUN: [ ! -s %T/testroot-clang/bin/x86_64-w64-mingw32-clang ] || rm %T/testroot-clang/bin/x86_64-w64-mingw32-clang
-// RUN: [ ! -s %T/testroot-clang/x86_64-w64-mingw32 ] || rm %T/testroot-clang/x86_64-w64-mingw32
 // RUN: ln -s %clang %T/testroot-clang/bin/x86_64-w64-mingw32-clang
 // RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %T/testroot-clang/x86_64-w64-mingw32
 

diff  --git a/clang/test/Driver/riscv32-toolchain-extra.c b/clang/test/Driver/riscv32-toolchain-extra.c
index 3182e0cfc1ae..f70092ac0333 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -12,10 +12,8 @@
 // runtime if and only if they exist.
 //
 // REQUIRES: platform-linker
+// RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc/bin
 // RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
-// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/clang ] || rm %T/testroot-riscv32-baremetal-nogcc/bin/clang
-// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld ] || rm %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
-// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf ] || rm %T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
 // RUN: ln -s %clang %T/testroot-riscv32-baremetal-nogcc/bin/clang
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf %T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf

diff  --git a/clang/test/Driver/riscv64-toolchain-extra.c b/clang/test/Driver/riscv64-toolchain-extra.c
index 081fc67e01cf..434f2dd2599a 100644
--- a/clang/test/Driver/riscv64-toolchain-extra.c
+++ b/clang/test/Driver/riscv64-toolchain-extra.c
@@ -12,10 +12,8 @@
 // runtime if and only if they exist.
 //
 // REQUIRES: platform-linker
+// RUN: rm -rf %T/testroot-riscv64-baremetal-nogcc/bin
 // RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
-// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/clang ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/clang
-// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
-// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf ] || rm %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
 // RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf

diff  --git a/clang/test/Driver/target-override.c b/clang/test/Driver/target-override.c
index 49ca90fd6f47..b4dbd2da1df6 100644
--- a/clang/test/Driver/target-override.c
+++ b/clang/test/Driver/target-override.c
@@ -1,8 +1,8 @@
 // REQUIRES: shell
 // REQUIRES: x86-registered-target
 
+// RUN: rm -rf %T/testbin
 // RUN: mkdir -p %T/testbin
-// RUN: [ ! -s %T/testbin/i386-clang ] || rm %T/testbin/i386-clang
 // RUN: ln -s %clang %T/testbin/i386-clang
 
 // Check if invocation of "foo-clang" adds option "-target foo".


        


More information about the cfe-commits mailing list