From ca58b6487e1f0a134d1becb1aa3e8924bb1f26c2 Mon Sep 17 00:00:00 2001 From: ajurkowski Date: Thu, 10 Feb 2022 16:51:24 -0800 Subject: [PATCH] Add a getter for arguments in `ParamFileActionInput`. Expand `DummyExecutor` to allow customizing `BugReporter` and `ShowSubcommands` for tests. PiperOrigin-RevId: 427875824 --- .../build/lib/actions/CommandLines.java | 4 +++ .../build/lib/actions/util/DummyExecutor.java | 25 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/actions/CommandLines.java b/src/main/java/com/google/devtools/build/lib/actions/CommandLines.java index 2678b055f1c6dc..0f45c0e0facfdb 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/CommandLines.java +++ b/src/main/java/com/google/devtools/build/lib/actions/CommandLines.java @@ -315,6 +315,10 @@ public String getExecPathString() { public PathFragment getExecPath() { return paramFileExecPath; } + + public ImmutableList getArguments() { + return ImmutableList.copyOf(arguments); + } } // Helper function to unpack the optimized storage format into a list diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/DummyExecutor.java b/src/test/java/com/google/devtools/build/lib/actions/util/DummyExecutor.java index 3423bcce80fce6..8d067ebc28f180 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/util/DummyExecutor.java +++ b/src/test/java/com/google/devtools/build/lib/actions/util/DummyExecutor.java @@ -28,15 +28,33 @@ public class DummyExecutor implements Executor { private final FileSystem fileSystem; + private final BugReporter bugReporter; private final Path inputDir; private final ManualClock clock = new ManualClock(); @Nullable private final OptionsProvider optionsProvider; + @Nullable private final ShowSubcommands showSubcommands; public DummyExecutor( - FileSystem fileSystem, Path inputDir, @Nullable OptionsProvider optionsProvider) { + FileSystem fileSystem, + BugReporter bugReporter, + Path inputDir, + @Nullable OptionsProvider optionsProvider, + @Nullable ShowSubcommands showSubcommands) { this.fileSystem = fileSystem; + this.bugReporter = bugReporter; this.inputDir = inputDir; this.optionsProvider = optionsProvider; + this.showSubcommands = showSubcommands; + } + + public DummyExecutor( + FileSystem fileSystem, Path inputDir, @Nullable OptionsProvider optionsProvider) { + this( + fileSystem, + BugReporter.defaultInstance(), + inputDir, + optionsProvider, + /*showSubcommands=*/ null); } public DummyExecutor(FileSystem fileSystem, Path inputDir) { @@ -64,7 +82,7 @@ public Clock getClock() { @Override public BugReporter getBugReporter() { - return BugReporter.defaultInstance(); + return bugReporter; } @Override @@ -82,6 +100,9 @@ public OptionsProvider getOptions() { @Override public ShowSubcommands reportsSubcommands() { + if (showSubcommands != null) { + return showSubcommands; + } throw new UnsupportedOperationException(); } }