// Copyright 2016 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.devtools.build.lib.windows; import java.io.PrintStream; import java.nio.charset.Charset; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; /** * Mock subprocess to be used for testing Windows process management. Command line usage: * *
I<register><count>
: Read count bytes to the specified register
* O-<string>
: Write a string to stdoutE-<string>
: Write a string to stderrO$<variable>
: Write an environment variable to stdoutE$<variable>
: Write an environment variable to stderrO.
: Write the cwd stdoutE.
: Write the cwd stderrO<register>
: Write the contents of a register to stdoutE<register>
: Write the contents of a register to stderrX<exit code%gt;
: Exit with the specified exit codeS<seconds>
: Wait the specified number of secondsRegisters are single characters. Each command line argument is interpreted as a single
* operation. Example:
*
*
* Ia10 Oa Oa Ea E-OVER X42
*
*
* Means: read 10 bytes from stdin, write them back twice to stdout and once to stderr, write
* the string "OVER" to stderr then exit with exit code 42.
*/
public class MockSubprocess {
private static Map