[PATCH] D83834: Add test utility 'extract'
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 17:31:34 PDT 2020
MaskRay created this revision.
MaskRay added reviewers: dblaikie, echristo, grimar, jhenderson, probinson, rsmith.
Herald added subscribers: llvm-commits, stephenneuendorffer, rriddle, mgorny.
Herald added a project: LLVM.
See https://lists.llvm.org/pipermail/llvm-dev/2020-July/143373.html
"[llvm-dev] Multiple documents in one test file" for some discussions.
`extract part filename` splits the input file into multiple parts separated by
regex `^(.|//)--- ` and extract the specified part to stdout or the
output file (if specified).
Use case A (organizing input of different formats (e.g. linker
script+assembly) in one file).
// RUN: extract lds %s -o %t.lds
// RUN: extract asm %s -o %t.s
// RUN: llvm-mc %t.s -o %t.o
// RUN: ld.lld -T %t.lds %t.o -o %t
This is sometimes better than the %S/Inputs/ approach because the user
can see the auxiliary files immediately and don't have to open another file.
Use case B (for utilities which don't have built-in input splitting
feature):
// RUN: extract case1 %s | llc | FileCheck %s --check-prefix=CASE1
// RUN: extract case2 %s | llc | FileCheck %s --check-prefix=CASE2
Combing tests prudently can improve readability.
This is sometimes better than having multiple test files.
Since this is a new utility, there is no git history concerns for
UpperCase variable names. I use lowerCase variable names like mlir/lld.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83834
Files:
llvm/test/CMakeLists.txt
llvm/test/lit.cfg.py
llvm/tools/extract/CMakeLists.txt
llvm/tools/extract/extract.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83834.278028.patch
Type: text/x-patch
Size: 5187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200715/762111ee/attachment.bin>
More information about the llvm-commits
mailing list