summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-ar
diff options
context:
space:
mode:
authorOwen Reynolds <gbreynoo@gmail.com>2019-09-19 10:51:43 +0000
committerOwen Reynolds <gbreynoo@gmail.com>2019-09-19 10:51:43 +0000
commit04398c729b20c16aa06bfab4330cf1831d1f8dec (patch)
tree27976771f78a295e636546646e43d253054465ea /llvm/test/tools/llvm-ar
parentda89495a3e73bfc02ffb7d881da1db628d1d0815 (diff)
downloadbcm5719-llvm-04398c729b20c16aa06bfab4330cf1831d1f8dec.tar.gz
bcm5719-llvm-04398c729b20c16aa06bfab4330cf1831d1f8dec.zip
[llvm-ar] Include a line number when failing to parse an MRI script
Errors that occur when reading an MRI script now include a corresponding line number. Differential Revision: https://reviews.llvm.org/D67449 llvm-svn: 372309
Diffstat (limited to 'llvm/test/tools/llvm-ar')
-rw-r--r--llvm/test/tools/llvm-ar/mri-addlib.test4
-rw-r--r--llvm/test/tools/llvm-ar/mri-errors.test41
2 files changed, 43 insertions, 2 deletions
diff --git a/llvm/test/tools/llvm-ar/mri-addlib.test b/llvm/test/tools/llvm-ar/mri-addlib.test
index b213fd9e5c1..ee692ea9fbd 100644
--- a/llvm/test/tools/llvm-ar/mri-addlib.test
+++ b/llvm/test/tools/llvm-ar/mri-addlib.test
@@ -22,10 +22,10 @@
# RUN: not llvm-ar -M < %t/badlib.mri 2>&1 | FileCheck --check-prefix=PARSE %s
# RUN: not ls %t/badlib.a
-# PARSE: error: could not parse library
+# PARSE: error: script line 2: could not parse library
## No create command.
-# RUN: echo "ADDLIB %t/f.a" > %t/nocreate.mri
+# RUN: echo "ADDLIB %t/f.a" > %t/nocreate.mri
# RUN: echo "SAVE" >> %t/nocreate.mri
# RUN: not llvm-ar -M < %t/nocreate.mri
diff --git a/llvm/test/tools/llvm-ar/mri-errors.test b/llvm/test/tools/llvm-ar/mri-errors.test
new file mode 100644
index 00000000000..a6980f27caf
--- /dev/null
+++ b/llvm/test/tools/llvm-ar/mri-errors.test
@@ -0,0 +1,41 @@
+## Test different MRI comment formats and whitespace.
+
+# RUN: rm -rf %t && mkdir -p %t
+
+# RUN: echo "create %t/mri.ar" > %t/script1.mri
+# RUN: echo "addlib %t/missing.a" >> %t/script1.mri
+
+# RUN: not llvm-ar -M < %t/script1.mri 2>&1 | FileCheck --check-prefix=SCRIPT1 %s
+# SCRIPT1: error: script line 2: could not open library
+
+# RUN: echo "create %t/mri.ar" > %t/script2.mri
+# RUN: echo "addlib %t/bad.a" >> %t/script2.mri
+
+# RUN: echo "bad archive" > %t/bad.a
+
+# RUN: not llvm-ar -M < %t/script2.mri 2>&1 | FileCheck --check-prefix=SCRIPT2 %s
+# SCRIPT2: error: script line 2: could not parse library
+
+# RUN: echo "create %t/mri.ar" > %t/script3.mri
+# RUN: echo "create %t/second.ar" >> %t/script3.mri
+
+# RUN: not llvm-ar -M < %t/script3.mri 2>&1 | FileCheck --check-prefix=SCRIPT3 %s
+# SCRIPT3: error: script line 2: editing multiple archives not supported
+
+# RUN: echo "save" > %t/script4.mri
+# RUN: echo "create %t/mri.ar" >> %t/script4.mri
+
+# RUN: not llvm-ar -M < %t/script4.mri 2>&1 | FileCheck --check-prefix=SCRIPT4 %s
+# SCRIPT4: error: script line 2: file already saved
+
+# RUN: echo "create %t/mri.ar" > %t/script5.mri
+# RUN: echo "bad command" >> %t/script5.mri
+
+# RUN: not llvm-ar -M < %t/script5.mri 2>&1 | FileCheck --check-prefix=SCRIPT5 %s
+# SCRIPT5: error: script line 2: unknown command: bad
+
+# RUN: echo "bad command" | not llvm-ar -M 2>&1 | FileCheck --check-prefix=SCRIPT6 %s
+# SCRIPT6: error: script line 1: unknown command: bad
+
+# RUN: not llvm-ar -M rc %t/mri.ar 2>&1 | FileCheck --check-prefix=SCRIPT7 %s
+# SCRIPT7: error: cannot mix -M and other options
OpenPOWER on IntegriCloud