rakedotnet 1.1.53 → 1.1.54

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/nunit.rb +9 -4
  2. data/spec/nunit_spec.rb +48 -12
  3. metadata +2 -2
@@ -4,6 +4,7 @@ require 'dotframeworksymbolhelp'
4
4
  module BradyW
5
5
  class Nunit < BaseTask
6
6
  include Dotframeworksymbolhelp
7
+ PROGRAM_FILES_DIR = "C:/Program Files (x86)"
7
8
 
8
9
  # *Required* Files/assemblies to test
9
10
  attr_accessor :files
@@ -14,7 +15,7 @@ module BradyW
14
15
  # *Optional* What version of the .NET framework to use for the tests? :v2_0, :v3_5, :v4_0, :v4_5, defaults to :v4_5
15
16
  attr_accessor :framework_version
16
17
 
17
- # *Optional* Location of nunit-console.exe, defaults to C:\Program Files (x86)\NUnit ${version}\bin
18
+ # *Optional* Full path of nunit-console.exe, defaults to C:\Program Files (x86)\NUnit ${version}\bin\nunit-console.exe
18
19
  attr_accessor :path
19
20
 
20
21
  # *Optional* Timeout for each test case in milliseconds, by default the timeout is 35 seconds
@@ -42,7 +43,7 @@ module BradyW
42
43
 
43
44
  def exectask
44
45
  assemblies = files.uniq.join(" ")
45
- shell "\"#{path}\\#{executable}\"#{output}#{errors}#{labels_flat}#{xml_output_flat}/framework=#{framework_version} /timeout=#{timeout}#{testsparam}#{assemblies}"
46
+ shell "\"#{full_path}\"#{output}#{errors}#{labels_flat}#{xml_output_flat}/framework=#{framework_version} /timeout=#{timeout}#{testsparam}#{assemblies}"
46
47
  end
47
48
 
48
49
  def executable
@@ -91,8 +92,12 @@ module BradyW
91
92
  convertToNumber(@framework_version || :v4_5)
92
93
  end
93
94
 
94
- def path
95
- @path || "C:\\Program Files (x86)\\NUnit #{version}\\bin"
95
+ def full_path
96
+ possibleDirectories = ["NUnit #{version}","NUnit-#{version}"]
97
+ candidates = @path ? [@path] : possibleDirectories.map {|p| File.join(PROGRAM_FILES_DIR,p,"bin",executable) }
98
+ found = candidates.detect {|c| File.exists? c}
99
+ return found if found
100
+ raise "We checked the following locations and could not find nunit-console.exe #{candidates}"
96
101
  end
97
102
 
98
103
  def timeout
@@ -3,13 +3,36 @@ require "nunit"
3
3
  require "basetaskmocking"
4
4
 
5
5
  describe BradyW::Nunit do
6
+ before(:each) do
7
+ File.stub(:exists?).with("C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe").and_return(true)
8
+ end
9
+
10
+ it 'throws error when NUnit could not be found' do
11
+ File.stub(:exists?).with("C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe").and_return(false)
12
+ File.stub(:exists?).with("C:/Program Files (x86)/NUnit-2.6.3/bin/nunit-console.exe").and_return(false)
13
+
14
+ task = BradyW::Nunit.new do |test|
15
+ test.files = ["file1.dll", "file2.dll"]
16
+ end
17
+ lambda {task.exectaskpublic}.should raise_exception("We checked the following locations and could not find nunit-console.exe [\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\", \"C:/Program Files (x86)/NUnit-2.6.3/bin/nunit-console.exe\"]")
18
+ end
19
+
20
+ it 'works when a ZIP file, not an MSI is installed, which has a different path' do
21
+ File.stub(:exists?).with("C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe").and_return(false)
22
+ File.stub(:exists?).with("C:/Program Files (x86)/NUnit-2.6.3/bin/nunit-console.exe").and_return(true)
23
+ task = BradyW::Nunit.new do |test|
24
+ test.files = ["file1.dll", "file2.dll"]
25
+ end
26
+ task.exectaskpublic
27
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit-2.6.3/bin/nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
28
+ end
6
29
 
7
30
  it 'shows correct default command line' do
8
31
  task = BradyW::Nunit.new do |test|
9
32
  test.files = ["file1.dll", "file2.dll"]
10
33
  end
11
34
  task.exectaskpublic
12
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
35
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
13
36
  end
14
37
 
15
38
  it 'doesnt test duplicate files' do
@@ -17,34 +40,46 @@ describe BradyW::Nunit do
17
40
  test.files = ["file1.dll", "file1.dll"]
18
41
  end
19
42
  task.exectaskpublic
20
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll"
43
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll"
21
44
  end
22
45
 
23
46
  it 'uses NUnit 2.6.1' do
47
+ File.stub(:exists?).with("C:/Program Files (x86)/NUnit 2.6.1/bin/nunit-console.exe").and_return(true)
24
48
  task = BradyW::Nunit.new do |test|
25
49
  test.files = ["file1.dll", "file2.dll"]
26
50
  test.version = "2.6.1"
27
51
  end
28
52
  task.exectaskpublic
29
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.1\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
53
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.1/bin/nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
30
54
  end
31
55
 
32
56
  it 'uses a configured custom path' do
57
+ File.stub(:exists?).with("C:\\SomeOtherplace\\nunit-console.exe").and_return(true)
33
58
  task = BradyW::Nunit.new do |test|
34
59
  test.files = ["file1.dll", "file2.dll"]
35
- test.path = "C:\\SomeOtherplace"
60
+ test.path = "C:\\SomeOtherplace\\nunit-console.exe"
36
61
  end
37
62
  task.exectaskpublic
38
63
  task.excecutedPop.should == "\"C:\\SomeOtherplace\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
39
64
  end
40
65
 
66
+ it 'uses a configured custom path and the console is not found' do
67
+ File.stub(:exists?).with("C:/SomeOtherplace/nunit-console.exe").and_return(false)
68
+ task = BradyW::Nunit.new do |test|
69
+ test.files = ["file1.dll", "file2.dll"]
70
+ test.path = "C:/SomeOtherplace/nunit-console.exe"
71
+ end
72
+
73
+ lambda {task.exectaskpublic}.should raise_exception "We checked the following locations and could not find nunit-console.exe [\"C:/SomeOtherplace/nunit-console.exe\"]"
74
+ end
75
+
41
76
  it 'uses a custom timeout' do
42
77
  task = BradyW::Nunit.new do |test|
43
78
  test.files = ["file1.dll", "file2.dll"]
44
79
  test.timeout = 25
45
80
  end
46
81
  task.exectaskpublic
47
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=25 file1.dll file2.dll"
82
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=25 file1.dll file2.dll"
48
83
  end
49
84
 
50
85
  it 'uses .NET 3.5' do
@@ -53,7 +88,7 @@ describe BradyW::Nunit do
53
88
  test.framework_version = :v3_5
54
89
  end
55
90
  task.exectaskpublic
56
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /labels /noxml /framework=3.5 /timeout=35000 file1.dll file2.dll"
91
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /labels /noxml /framework=3.5 /timeout=35000 file1.dll file2.dll"
57
92
  end
58
93
 
59
94
  it 'can handle a single specific test to run' do
@@ -63,7 +98,7 @@ describe BradyW::Nunit do
63
98
  end
64
99
 
65
100
  task.exectaskpublic
66
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 /run=some.test file1.dll file2.dll"
101
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 /run=some.test file1.dll file2.dll"
67
102
  end
68
103
 
69
104
  it 'can handle a multiple specific tests to run' do
@@ -73,7 +108,7 @@ describe BradyW::Nunit do
73
108
  end
74
109
 
75
110
  task.exectaskpublic
76
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 /run=some.test,some.other.test file1.dll file2.dll"
111
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 /run=some.test,some.other.test file1.dll file2.dll"
77
112
  end
78
113
 
79
114
  it 'should work OK if XML output is turned on' do
@@ -82,7 +117,7 @@ describe BradyW::Nunit do
82
117
  test.xml_output = :enabled
83
118
  end
84
119
  task.exectaskpublic
85
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /labels /framework=4.5 /timeout=35000 file1.dll file2.dll"
120
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /labels /framework=4.5 /timeout=35000 file1.dll file2.dll"
86
121
 
87
122
  end
88
123
 
@@ -92,7 +127,7 @@ describe BradyW::Nunit do
92
127
  test.labels = :exclude_labels
93
128
  end
94
129
  task.exectaskpublic
95
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
130
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
96
131
 
97
132
  end
98
133
 
@@ -103,16 +138,17 @@ describe BradyW::Nunit do
103
138
  test.errors = "someerrorfile.txt"
104
139
  end
105
140
  task.exectaskpublic
106
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe\" /output=somefile.txt /err=someerrorfile.txt /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
141
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console.exe\" /output=somefile.txt /err=someerrorfile.txt /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
107
142
  end
108
143
 
109
144
  it 'Should work OK with x86 arch' do
145
+ File.stub(:exists?).with("C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console-x86.exe").and_return(true)
110
146
  task = BradyW::Nunit.new do |test|
111
147
  test.files = ["file1.dll", "file2.dll"]
112
148
  test.arch = :x86
113
149
  end
114
150
  task.exectaskpublic
115
- task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console-x86.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
151
+ task.excecutedPop.should == "\"C:/Program Files (x86)/NUnit 2.6.3/bin/nunit-console-x86.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
116
152
 
117
153
  end
118
154
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakedotnet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.53
4
+ version: 1.1.54
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: 78227580219478976
92
+ hash: -1866239646096198207
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements: