[lld-macho] Disable colors in errors when not printing to a pty
authorJez Ng <jezng@fb.com>
Wed, 29 Apr 2020 22:42:32 +0000 (15:42 -0700)
committerShoaib Meenai <smeenai@fb.com>
Wed, 29 Apr 2020 22:44:35 +0000 (15:44 -0700)
This makes for better tests (and is just the right thing to do)

Differential Revision: https://reviews.llvm.org/D79069

lld/MachO/Driver.cpp
lld/test/MachO/alignment-too-large.yaml
lld/test/MachO/arch.s
lld/test/MachO/duplicate-symbol.s
lld/test/MachO/entry-symbol.s
lld/test/MachO/invalid-executable.s
lld/test/MachO/missing-dylib.s
lld/test/MachO/no-id-dylink.s
lld/test/MachO/no-such-file.s
lld/test/MachO/silent-ignore.test

index abf5c09..e230fb2 100644 (file)
@@ -119,6 +119,9 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
   lld::stdoutOS = &stdoutOS;
   lld::stderrOS = &stderrOS;
 
+  stderrOS.enable_colors(stderrOS.has_colors());
+  // TODO: Set up error handler properly, e.g. the errorLimitExceededMsg
+
   MachOOptTable parser;
   opt::InputArgList args = parser.parse(argsArr.slice(1));
 
index 18d133f..7995052 100644 (file)
@@ -1,7 +1,7 @@
 # RUN: yaml2obj %s -o %t.o
 # RUN: not lld -flavor darwinnew -o %t %t.o 2>&1 | FileCheck %s
 #
-# CHECK: alignment 32 of section __text is too large
+# CHECK: error: alignment 32 of section __text is too large
 --- !mach-o
 FileHeader:
   magic:           0xFEEDFACF
index 3136549..e119eb9 100644 (file)
@@ -2,7 +2,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-darwin %s -o %t.o
 # RUN: lld -flavor darwinnew -arch x86_64 -o /dev/null %t.o
 # RUN: not lld -flavor darwinnew -arch i386 -o /dev/null %t.o 2>&1 | FileCheck %s
-# CHECK: missing or unsupported -arch i386
+# CHECK: error: missing or unsupported -arch i386
 
 .text
 .global _main
index 47f597f..d08f34f 100644 (file)
@@ -3,7 +3,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t-dup.o
 # RUN: not lld -flavor darwinnew -o /dev/null %t-dup.o %t.o 2>&1 | FileCheck %s
 
-# CHECK: duplicate symbol: _main
+# CHECK: error: duplicate symbol: _main
 
 .text
 .global _main
index 1890f40..31ad840 100644 (file)
@@ -2,10 +2,10 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
 # RUN: lld -flavor darwinnew -o /dev/null %t.o -e _not_main
 # RUN: not lld -flavor darwinnew -o /dev/null %t.o -e _missing 2>&1 | FileCheck %s
-# RUN: not lld -flavor darwinnew -o /dev/null %t.o 2>&1 | FileCheck %s --check-prefix=DEFAULT_ENTRY
+# RUN: not lld -flavor darwinnew -o /dev/null %t.o 2>&1 | FileCheck %s --check-prefix=DEFAULT-ENTRY
 
-# CHECK: undefined symbol: _missing
-# DEFAULT_ENTRY: undefined symbol: _main
+# CHECK: error: undefined symbol: _missing
+# DEFAULT-ENTRY: error: undefined symbol: _main
 
 .text
 .global _not_main
index 9ad9f51..d8d7acc 100644 (file)
@@ -1,8 +1,8 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-darwin %s -o %t.o
 # RUN: lld -flavor darwinnew -o %t %t.o
-# RUN: not lld -flavor darwinnew -o /dev/null %t 2>&1 | FileCheck %s
-# CHECK: unhandled file type
+# RUN: not lld -flavor darwinnew -o /dev/null %t 2>&1 | FileCheck %s -DFILE=%t
+# CHECK: error: [[FILE]]: unhandled file type
 
 .text
 .global _main
index d66ff52..ad7e511 100644 (file)
@@ -2,4 +2,4 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
 # RUN: not lld -flavor darwinnew -Z -o %t -lmissing %t.o 2>&1 | FileCheck %s
 
-# CHECK: library not found for -lmissing
+# CHECK: error: library not found for -lmissing
index 2fcd10d..7353b40 100644 (file)
@@ -3,7 +3,7 @@
 # RUN: yaml2obj %p/Inputs/no-id-dylib.yaml -o %t/libnoid.dylib
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/no-id-dylink.o
 # RUN: not lld -flavor darwinnew -o %t/no-id-dylink -Z -L%t -lnoid %t/no-id-dylink.o 2>&1 | FileCheck %s
-# CHECK: dylib {{.*}}libnoid.dylib missing LC_ID_DYLIB load command
+# CHECK: error: dylib {{.*}}libnoid.dylib missing LC_ID_DYLIB load command
 
 .text
 .globl _main
index 840b8f9..0122c61 100644 (file)
@@ -1,4 +1,4 @@
 # REQUIRES: x86
 # RUN: not lld -flavor darwinnew -o /dev/null %t-no-such-file.o 2>&1 | FileCheck %s
 
-# CHECK: cannot open {{.*}}no-such-file.o
+# CHECK: error: cannot open {{.*}}no-such-file.o
index e863aac..de95cff 100644 (file)
@@ -5,4 +5,4 @@ RUN:   -no_deduplicate \
 RUN:   -lto_library /lib/foo \
 RUN:   -macosx_version_min 0
 RUN: not lld -flavor darwinnew -v --not-an-ignored-argument 2>&1 | FileCheck %s
-CHECK: unknown argument: --not-an-ignored-argument
+CHECK: error: unknown argument: --not-an-ignored-argument