13
13
14
14
using namespace llvm ;
15
15
16
- TestRunner::TestRunner (StringRef TestName,
17
- const std::vector<std::string> &TestArgs,
16
+ TestRunner::TestRunner (StringRef TestName, ArrayRef<std::string> RawTestArgs,
18
17
std::unique_ptr<ReducerWorkItem> Program,
19
18
std::unique_ptr<TargetMachine> TM, StringRef ToolName,
20
19
StringRef OutputName, bool InputIsBitcode,
21
20
bool OutputBitcode)
22
- : TestName(TestName), ToolName(ToolName), TestArgs(TestArgs),
23
- Program(std::move(Program)), TM(std::move(TM)),
24
- OutputFilename(OutputName), InputIsBitcode(InputIsBitcode),
25
- EmitBitcode(OutputBitcode) {
21
+ : TestName(TestName), ToolName(ToolName), Program(std::move(Program)),
22
+ TM(std::move(TM)), OutputFilename(OutputName),
23
+ InputIsBitcode(InputIsBitcode), EmitBitcode(OutputBitcode) {
26
24
assert (this ->Program && " Initialized with null program?" );
25
+
26
+ TestArgs.push_back (TestName); // argv[0]
27
+ TestArgs.append (RawTestArgs.begin (), RawTestArgs.end ());
27
28
}
28
29
29
30
static constexpr std::array<std::optional<StringRef>, 3 > DefaultRedirects = {
@@ -33,18 +34,13 @@ static constexpr std::array<std::optional<StringRef>, 3> NullRedirects;
33
34
// / Runs the interestingness test, passes file to be tested as first argument
34
35
// / and other specified test arguments after that.
35
36
int TestRunner::run (StringRef Filename) const {
36
- std::vector<StringRef> ProgramArgs;
37
- ProgramArgs.push_back (TestName);
38
-
39
- for (const auto &Arg : TestArgs)
40
- ProgramArgs.push_back (Arg);
41
-
42
- ProgramArgs.push_back (Filename);
37
+ SmallVector<StringRef> ExecArgs (TestArgs);
38
+ ExecArgs.push_back (Filename);
43
39
44
40
std::string ErrMsg;
45
41
46
42
int Result =
47
- sys::ExecuteAndWait (TestName, ProgramArgs , /* Env=*/ std::nullopt,
43
+ sys::ExecuteAndWait (TestName, ExecArgs , /* Env=*/ std::nullopt,
48
44
Verbose ? DefaultRedirects : NullRedirects,
49
45
/* SecondsToWait=*/ 0 , /* MemoryLimit=*/ 0 , &ErrMsg);
50
46
0 commit comments