rcomp 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,30 +19,26 @@ module RComp
19
19
  case test.result
20
20
  # success
21
21
  when :success
22
- case @type
23
- when :test
24
- puts "\t passed : #{test.relative_path}"
25
- when :generate
22
+ if @type == :test
23
+ puts "\tpassed : #{test.relative_path}"
24
+ else
26
25
  puts "\tgenerated : #{test.relative_path}"
27
26
  end
28
27
  @success += 1
29
28
 
30
29
  # skipped
31
30
  when :skipped
32
- case @type
33
- when :test
34
- puts "\tskipped : #{test.relative_path}"
35
- when :generate
36
- puts "\t skipped : #{test.relative_path}"
37
- end
31
+ puts "\tskipped : #{test.relative_path}"
38
32
  @skipped += 1
39
33
 
40
34
  # failed
41
35
  when :failed
42
- case @type
43
- when :test
44
- puts "\t failed : #{test.relative_path}"
45
- end
36
+ puts "\tfailed : #{test.relative_path}"
37
+ @failed += 1
38
+
39
+ # timedout
40
+ when :timedout
41
+ puts "\ttimeout : #{test.relative_path}"
46
42
  @failed += 1
47
43
  end
48
44
  end
@@ -71,7 +67,8 @@ module RComp
71
67
 
72
68
  def print_generate_summary
73
69
  desc = []
74
- summary = "#{plural((@skipped + @success), 'file')} ("
70
+ summary = "#{plural((@failed + @skipped + @success), 'file')} ("
71
+ desc << "#{@failed} failed" unless @failed == 0
75
72
  desc << "#{@skipped} skipped" unless @skipped == 0
76
73
  desc << "#{@success} generated" unless @success == 0
77
74
  summary += desc.join(", ") + ")"
data/lib/rcomp/runner.rb CHANGED
@@ -19,15 +19,13 @@ module RComp
19
19
  suite.each do |test|
20
20
  case type
21
21
  when :test
22
- if expected_exists?(test)
23
- run_test(test)
24
- end
22
+ run(test) if expected_exists?(test)
25
23
 
26
24
  when :generate
27
25
  if expected_exists?(test)
28
- run_generate(test) if options[:overwrite]
26
+ run(test, true) if options[:overwrite]
29
27
  else
30
- run_generate(test)
28
+ run(test, true)
31
29
  end
32
30
  end
33
31
 
@@ -50,28 +48,28 @@ module RComp
50
48
  File.exists?(test.expected_err_path)
51
49
  end
52
50
 
53
- # Run a test storing it's result out and err
51
+ # Test or generate output for a specified test
54
52
  #
55
53
  # test - A Test object
54
+ # generate - Flag for running generate. Runs test otherwise.
56
55
  #
57
56
  # Returns nothing
58
- def run_test(test)
59
- mkpath_to test.result_out_path
60
- mkpath_to test.result_err_path
61
- system "#{@conf.command} #{test.test_path} > #{test.result_out_path} 2> #{test.result_err_path}"
62
- test.result = compare_output(test)
63
- end
57
+ def run(test, generate=false)
58
+ generate ? mkpath_to(test.expected_out_path) :
59
+ mkpath_to(test.result_out_path)
64
60
 
65
- # Generate expected output for a test
66
- #
67
- # test - A Test object
68
- #
69
- # Returns nothing
70
- def run_generate(test)
71
- mkpath_to test.expected_out_path
72
- mkpath_to test.expected_err_path
73
- system "#{@conf.command} #{test.test_path} > #{test.expected_out_path} 2> #{test.expected_err_path}"
74
- test.result = :success
61
+ # Create process and run
62
+ cmd = [@conf.command, test.test_path]
63
+ out = generate ? test.expected_out_path : test.result_out_path
64
+ err = generate ? test.expected_err_path : test.result_err_path
65
+ process = Process.new(cmd, @conf.timeout, out, err)
66
+ process.run
67
+
68
+ if process.timedout?
69
+ test.result = :timedout
70
+ else
71
+ test.result = generate ? :success : compare_output(test)
72
+ end
75
73
  end
76
74
 
77
75
  # Compare the result and expected output of a test that has been run
data/lib/rcomp/suite.rb CHANGED
@@ -5,6 +5,8 @@ module RComp
5
5
 
6
6
  include RComp::Path
7
7
 
8
+ @@conf = Conf.instance
9
+
8
10
  # Create a test suite
9
11
  #
10
12
  # pattern - A pattern to filter the tests that are added to the suite
@@ -14,7 +16,7 @@ module RComp
14
16
  tests = []
15
17
 
16
18
  # Find all tests in the tests directory
17
- Find.find Conf.instance.test_root do |path|
19
+ Find.find @@conf.test_root do |path|
18
20
  # recurse into all subdirectories
19
21
  next if File.directory? path
20
22
 
@@ -26,10 +28,25 @@ module RComp
26
28
  # ignore dotfiles
27
29
  next if File.basename(path).match(/^\..*/)
28
30
 
31
+ # ignore files in ignore filter
32
+ next if ignored?(path)
33
+
29
34
  tests << Test.new(path)
30
35
  end
31
36
 
32
- tests
37
+ return tests
38
+ end
39
+
40
+ # Checks all ignore patterns against a given relative path
41
+ #
42
+ # path - A relative path of a test
43
+ #
44
+ # Returns true if any patterns match the path, false otherwise
45
+ def ignored?(path)
46
+ @@conf.ignore.each do |ignore|
47
+ return true if rel_path(path).match(ignore)
48
+ end
49
+ return false
33
50
  end
34
51
  end
35
52
  end
data/lib/rcomp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RComp
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
data/rcomp.gemspec CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_runtime_dependency("thor", "~> 0.16.0")
25
-
26
- s.add_development_dependency("rake")
27
- s.add_development_dependency("cucumber", "~> 1.2.1")
28
- s.add_development_dependency("aruba", "~> 0.5.0")
24
+ s.add_runtime_dependency "thor", "~> 0.16.0"
25
+ s.add_runtime_dependency "childprocess", "~> 0.3.6"
26
+ s.add_development_dependency "rake"
27
+ s.add_development_dependency "cucumber", "~> 1.2.1"
28
+ s.add_development_dependency "aruba", "~> 0.5.0"
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-20 00:00:00.000000000 Z
12
+ date: 2012-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.16.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: childprocess
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.3.6
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.6
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: rake
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -96,8 +112,8 @@ files:
96
112
  - contributing.md
97
113
  - features/generate.feature
98
114
  - features/init.feature
99
- - features/set_command.feature
100
- - features/set_directory.feature
115
+ - features/step_definitions/test_steps.rb
116
+ - features/step_definitions/version_steps.rb
101
117
  - features/support/env.rb
102
118
  - features/test.feature
103
119
  - features/version.feature
@@ -106,7 +122,9 @@ files:
106
122
  - lib/rcomp/cli.rb
107
123
  - lib/rcomp/conf.rb
108
124
  - lib/rcomp/helper.rb
125
+ - lib/rcomp/initializer.rb
109
126
  - lib/rcomp/path.rb
127
+ - lib/rcomp/process.rb
110
128
  - lib/rcomp/reporter.rb
111
129
  - lib/rcomp/runner.rb
112
130
  - lib/rcomp/suite.rb
@@ -141,8 +159,8 @@ summary: A simple framework for testing command line application output.
141
159
  test_files:
142
160
  - features/generate.feature
143
161
  - features/init.feature
144
- - features/set_command.feature
145
- - features/set_directory.feature
162
+ - features/step_definitions/test_steps.rb
163
+ - features/step_definitions/version_steps.rb
146
164
  - features/support/env.rb
147
165
  - features/test.feature
148
166
  - features/version.feature
@@ -1,24 +0,0 @@
1
- Feature: Set Command
2
- A user should be able to set the command RComp tests with from the CLI
3
-
4
- @announce
5
- Scenario: Set command
6
- When I run `rcomp set-command ./test_exec`
7
- Then a file named ".rcomp" should exist
8
- And the file ".rcomp" should contain "command: ./test_exec"
9
- And the exit status should be 0
10
-
11
- @announce
12
- Scenario: Set command alias
13
- When I run `rcomp c ./test_exec`
14
- Then a file named ".rcomp" should exist
15
- And the file ".rcomp" should contain "command: ./test_exec"
16
- And the exit status should be 0
17
-
18
- @announce
19
- Scenario: Overwrite command
20
- When I run `rcomp c ./first`
21
- And I run `rcomp c ./second`
22
- Then a file named ".rcomp" should exist
23
- And the file ".rcomp" should contain "command: ./second"
24
- And the exit status should be 0
@@ -1,22 +0,0 @@
1
- Feature: Set Directory
2
- A user should be able to set the directory that RComp
3
- stores tests in from the CLI
4
-
5
- Scenario: Set directory
6
- When I run `rcomp set-directory spec/rcomp`
7
- Then a file named ".rcomp" should exist
8
- And the file ".rcomp" should contain "directory: spec/rcomp"
9
- And the exit status should be 0
10
-
11
- Scenario: Set directory alias
12
- When I run `rcomp d spec/rcomp`
13
- Then a file named ".rcomp" should exist
14
- And the file ".rcomp" should contain "directory: spec/rcomp"
15
- And the exit status should be 0
16
-
17
- Scenario: Overwrite directory
18
- When I run `rcomp d first`
19
- And I run `rcomp d second`
20
- Then a file named ".rcomp" should exist
21
- And the file ".rcomp" should contain "directory: second"
22
- And the exit status should be 0