Class: Testrus::Runner::Run
- Inherits:
-
Object
- Object
- Testrus::Runner::Run
- Defined in:
- lib/testrus/runner/run.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Public: Extracts the output against the input from the entire output which also inclues the time and memory information.
-
#test ⇒ Object
readonly
Returns the value of attribute test.
Instance Method Summary collapse
-
#initialize(output, test) ⇒ Run
constructor
Responsible for extracting data from the run of the program.
-
#memory_usage ⇒ Object
Public: Extracts the memory usage from the output.
-
#passed? ⇒ Boolean
Public: Boolean value of whether the test passed.
-
#real_time ⇒ Object
Public: Extracts the real time from the output.
-
#sys_time ⇒ Object
Public: Extracts the sys time from the output.
-
#user_time ⇒ Object
Public: Extracts the user time from the output.
-
#within_constraints? ⇒ Boolean
Public: Within usual constraints for time and memory.
Constructor Details
#initialize(output, test) ⇒ Run
Responsible for extracting data from the run of the program. See the public methods for what information can be extracted. This class only reads output that is run with the command: ‘/usr/bin/time -l #program`.
TODO: Test if this runner works on all UNIX-based operating systems, or only OS X.
output - The String output from the command ‘/usr/bin/time -l program` test - The Test that the input origins from.
16 17 18 19 |
# File 'lib/testrus/runner/run.rb', line 16 def initialize(output, test) @output = output @test = test end |
Instance Attribute Details
#output ⇒ Object (readonly)
Public: Extracts the output against the input from the entire output which also inclues the time and memory information.
53 54 55 |
# File 'lib/testrus/runner/run.rb', line 53 def output @output end |
#test ⇒ Object (readonly)
Returns the value of attribute test.
4 5 6 |
# File 'lib/testrus/runner/run.rb', line 4 def test @test end |
Instance Method Details
#memory_usage ⇒ Object
Public: Extracts the memory usage from the output.
22 23 24 |
# File 'lib/testrus/runner/run.rb', line 22 def memory_usage bytes_to_mb(raw_memory_usage) end |
#passed? ⇒ Boolean
Public: Boolean value of whether the test passed.
42 43 44 |
# File 'lib/testrus/runner/run.rb', line 42 def passed? output == @test.expected_output end |
#real_time ⇒ Object
Public: Extracts the real time from the output.
27 28 29 |
# File 'lib/testrus/runner/run.rb', line 27 def real_time time "real" end |
#sys_time ⇒ Object
Public: Extracts the sys time from the output.
37 38 39 |
# File 'lib/testrus/runner/run.rb', line 37 def sys_time time "sys" end |
#user_time ⇒ Object
Public: Extracts the user time from the output.
32 33 34 |
# File 'lib/testrus/runner/run.rb', line 32 def user_time time "user" end |
#within_constraints? ⇒ Boolean
Public: Within usual constraints for time and memory
47 48 49 |
# File 'lib/testrus/runner/run.rb', line 47 def within_constraints? memory_usage <= 64.00 && real_time <= 1.00 end |