You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	Provide getters for stdout, stderr on ShellRunner, ExecRunner (#1787)
* Provide getters for stdout, stderr on ShellRunner, ExecRunner we need that in order to set the streams back in case we have to scan the command output ourselvs during some function calls.
This commit is contained in:
		| @@ -30,6 +30,8 @@ type runner interface { | ||||
| 	AppendEnv(env []string) | ||||
| 	Stdout(out io.Writer) | ||||
| 	Stderr(err io.Writer) | ||||
| 	GetStdout() io.Writer | ||||
| 	GetStderr() io.Writer | ||||
| } | ||||
|  | ||||
| // ExecRunner mock for intercepting calls to executables | ||||
| @@ -70,6 +72,16 @@ func (c *Command) Stderr(stderr io.Writer) { | ||||
| 	c.stderr = stderr | ||||
| } | ||||
|  | ||||
| // GetStdout Returns the writer for stdout | ||||
| func (c *Command) GetStdout() io.Writer { | ||||
| 	return c.stdout | ||||
| } | ||||
|  | ||||
| //GetStderr Retursn the writer for stderr | ||||
| func (c *Command) GetStderr() io.Writer { | ||||
| 	return c.stderr | ||||
| } | ||||
|  | ||||
| // ExecCommand defines how to execute os commands | ||||
| var ExecCommand = exec.Command | ||||
|  | ||||
|   | ||||
| @@ -90,10 +90,18 @@ func (m *ExecMockRunner) Stdout(out io.Writer) { | ||||
| 	m.stdout = out | ||||
| } | ||||
|  | ||||
| func (m *ExecMockRunner) GetStdout() io.Writer { | ||||
| 	return m.stdout | ||||
| } | ||||
|  | ||||
| func (m *ExecMockRunner) Stderr(err io.Writer) { | ||||
| 	m.stderr = err | ||||
| } | ||||
|  | ||||
| func (m *ExecMockRunner) GetStderr() io.Writer { | ||||
| 	return m.stderr | ||||
| } | ||||
|  | ||||
| func (m *ShellMockRunner) SetDir(d string) { | ||||
| 	m.Dir = d | ||||
| } | ||||
| @@ -189,6 +197,14 @@ func (m *ShellMockRunner) Stdout(out io.Writer) { | ||||
| 	m.stdout = out | ||||
| } | ||||
|  | ||||
| func (m *ShellMockRunner) GetStdout() io.Writer { | ||||
| 	return m.stdout | ||||
| } | ||||
|  | ||||
| func (m *ShellMockRunner) GetStderr() io.Writer { | ||||
| 	return m.stderr | ||||
| } | ||||
|  | ||||
| func (m *ShellMockRunner) Stderr(err io.Writer) { | ||||
| 	m.stderr = err | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user