xref: /llvm-project/llvm/test/tools/llvm-ar/response.test (revision fe3b621f05e706fb04dec121c136b6de82a9e277)
162fa3332Sgbreynoo## llvm-ar should be able to consume response files.
262fa3332Sgbreynoo
362fa3332Sgbreynoo# RUN: echo 'contents' > %t.txt
462fa3332Sgbreynoo# RUN: echo 'rc %t1.a %t.txt' > %t.response1.txt
562fa3332Sgbreynoo# RUN: llvm-ar @%t.response1.txt
662fa3332Sgbreynoo# RUN: llvm-ar p %t1.a | FileCheck %s --check-prefix=CONTENTS
762fa3332Sgbreynoo
862fa3332Sgbreynoo## Quotes and Spaces.
962fa3332Sgbreynoo# RUN: echo 'contents' > '%t space.txt'
1062fa3332Sgbreynoo## Python is used here to ensure the quotes are written to the response file
1162fa3332Sgbreynoo# RUN: %python -c "import os; open(r'%t.response2.txt', 'w').write(r'%t2.a \"%t space.txt\"'+ '\n')"
1262fa3332Sgbreynoo# RUN: llvm-ar rc @%t.response2.txt
1362fa3332Sgbreynoo# RUN: llvm-ar p %t2.a | FileCheck %s --check-prefix=CONTENTS
1462fa3332Sgbreynoo
1562fa3332Sgbreynoo## Arguments after the response file.
1662fa3332Sgbreynoo# RUN: echo 'rc %t3.a' > %t.response3.txt
1762fa3332Sgbreynoo# RUN: llvm-ar @%t.response3.txt %t.txt
1862fa3332Sgbreynoo# RUN: llvm-ar p %t3.a | FileCheck %s --check-prefix=CONTENTS
1962fa3332Sgbreynoo
205e0f9d5dSgbreynoo## Newlines
215e0f9d5dSgbreynoo# RUN: echo contents > %t.txt
225e0f9d5dSgbreynoo# RUN: echo rc %t4.a > %t.newline.txt
235e0f9d5dSgbreynoo# RUN: echo %t.txt >> %t.newline.txt
245e0f9d5dSgbreynoo# RUN: llvm-ar @%t.newline.txt
255e0f9d5dSgbreynoo# RUN: llvm-ar p %t4.a | FileCheck %s --check-prefix=CONTENTS
265e0f9d5dSgbreynoo
2762fa3332Sgbreynoo# CONTENTS: contents
2862fa3332Sgbreynoo
2962fa3332Sgbreynoo## rsp-quoting
3062fa3332Sgbreynoo# RUN: not llvm-ar --rsp-quoting=foobar @%t.response1.txt 2>&1 | \
3162fa3332Sgbreynoo# RUN:   FileCheck  %s --check-prefix=ERROR
3262fa3332Sgbreynoo# ERROR: Invalid response file quoting style foobar
3362fa3332Sgbreynoo
3462fa3332Sgbreynoo# RUN: echo -e 'rc %/t.a blah\\foo' > %t-rsp.txt
3562fa3332Sgbreynoo# RUN: not llvm-ar --rsp-quoting=windows @%t-rsp.txt 2>&1 | \
3642a21778SAbhina Sreeskantharajan# RUN:   FileCheck -DMSG=%errc_ENOENT %s --check-prefix=WIN
3742a21778SAbhina Sreeskantharajan# WIN: error: blah\foo: [[MSG]]
3862fa3332Sgbreynoo
39*24e7371fSFangrui Song# RUN: not llvm-ar --rsp-quoting posix @%t-rsp.txt 2>&1 | \
4042a21778SAbhina Sreeskantharajan# RUN:   FileCheck -DMSG=%errc_ENOENT %s --check-prefix=POSIX
4142a21778SAbhina Sreeskantharajan# POSIX: error: blahfoo: [[MSG]]
42