Class: PmdTester::Cmd
- Inherits:
-
Object
- Object
- PmdTester::Cmd
- Extended by:
- PmdTester
- Defined in:
- lib/pmdtester/cmd.rb
Overview
Containing the common method for executing shell command
Constant Summary
Constants included from PmdTester
BASE, PATCH, PR_NUM_ENV_VAR, VERSION
Class Method Summary collapse
-
.execute(cmd, path) ⇒ Object
Executes the given command and returns the process status.
- .execute_successfully(cmd) ⇒ Object
- .stderr_of(cmd) ⇒ Object
Methods included from PmdTester
Class Method Details
.execute(cmd, path) ⇒ Object
Executes the given command and returns the process status. stdout and stderr are written to the files “stdout.txt” and “stderr.txt” in path.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pmdtester/cmd.rb', line 15 def self.execute(cmd, path) stdout, stderr, status = internal_execute(cmd) file = File.new("#{path}/stdout.txt", 'w') file.puts stdout file.close file = File.new("#{path}/stderr.txt", 'w') file.puts stderr file.close status end |
.execute_successfully(cmd) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pmdtester/cmd.rb', line 29 def self.execute_successfully(cmd) stdout, stderr, status = internal_execute(cmd) unless status.success? logger.error "Command failed: #{cmd}" logger.error stdout logger.error stderr raise CmdException.new(cmd, stdout, stderr, status) end stdout end |
.stderr_of(cmd) ⇒ Object
42 43 44 45 |
# File 'lib/pmdtester/cmd.rb', line 42 def self.stderr_of(cmd) _stdout, stderr, _status = internal_execute(cmd) stderr end |