Skip to content

Commit

Permalink
Add a getter for arguments in ParamFileActionInput.
Browse files Browse the repository at this point in the history
Expand `DummyExecutor` to allow customizing `BugReporter` and `ShowSubcommands` for tests.

PiperOrigin-RevId: 427875824
  • Loading branch information
alexjski authored and Copybara-Service committed Feb 11, 2022
1 parent 21f679c commit ca58b64
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ public String getExecPathString() {
public PathFragment getExecPath() {
return paramFileExecPath;
}

public ImmutableList<String> getArguments() {
return ImmutableList.copyOf(arguments);
}
}

// Helper function to unpack the optimized storage format into a list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -64,7 +82,7 @@ public Clock getClock() {

@Override
public BugReporter getBugReporter() {
return BugReporter.defaultInstance();
return bugReporter;
}

@Override
Expand All @@ -82,6 +100,9 @@ public OptionsProvider getOptions() {

@Override
public ShowSubcommands reportsSubcommands() {
if (showSubcommands != null) {
return showSubcommands;
}
throw new UnsupportedOperationException();
}
}

0 comments on commit ca58b64

Please sign in to comment.