pre_push 0.0.1.2 → 0.0.1.3
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.
- data/.gitignore +4 -1
- data/lib/pre_push/version.rb +1 -1
- data/lib/pre_push.rb +31 -8
- data/lib/prepush_validator.rb +3 -3
- data/lib/runners_config/mspec.rb +1 -0
- data/lib/runners_config/nunit262.rb +1 -0
- data/lib/runners_config/xunit191.rb +1 -0
- data/spec/pre_push_spec.rb +32 -4
- data/spec/prepush_validator_spec.rb +2 -2
- metadata +9 -12
- data/spec/TestProj/TestProj/TestProj.csproj.user +0 -6
- data/spec/TestProj/TestProj/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
- data/spec/TestProj/TestProj.suo +0 -0
data/.gitignore
CHANGED
data/lib/pre_push/version.rb
CHANGED
data/lib/pre_push.rb
CHANGED
@@ -2,6 +2,8 @@ require "pre_push/version"
|
|
2
2
|
|
3
3
|
module PrePush
|
4
4
|
module ClassMethods
|
5
|
+
attr :runner
|
6
|
+
MSBuildPaths = {:clr4 => 'C:/Windows/Microsoft.NET/Framework/v4.0.30319', :clr2 => 'C:/Windows/Microsoft.NET/Framework/v2.0.50727'}
|
5
7
|
def run
|
6
8
|
success = build
|
7
9
|
if (!success)
|
@@ -16,7 +18,12 @@ module PrePush
|
|
16
18
|
end
|
17
19
|
def build
|
18
20
|
set_exes_cache
|
19
|
-
|
21
|
+
clr = @clr == nil ? :clr4 : @clr.to_sym
|
22
|
+
if MSBuildPaths[clr] == nil
|
23
|
+
puts 'please assign clr2 or clr4 to @clr'
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
msbuild = "#{MSBuildPaths[clr]}/MSBuild.exe"
|
20
27
|
system "#{msbuild} #{@solution}"
|
21
28
|
$?.success?
|
22
29
|
end
|
@@ -37,12 +44,13 @@ module PrePush
|
|
37
44
|
def set_exes_cache
|
38
45
|
if (@runners_exes == nil || @runners_exes.empty?) then
|
39
46
|
@runners_exes = {}
|
40
|
-
|
41
|
-
|
42
|
-
Dir.entries(
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
bin = File.dirname(__FILE__)
|
48
|
+
config_dir = "#{bin}/../lib/runners_config"
|
49
|
+
Dir.entries(config_dir).select{|f| !File.directory? f}.each do |file|
|
50
|
+
load "#{bin}/../lib/runners_config/#{file}"
|
51
|
+
name = file.gsub('.rb','')
|
52
|
+
@runners_exes[name] = Container.runner
|
53
|
+
end
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
@@ -51,4 +59,19 @@ module PrePush
|
|
51
59
|
receiver.extend ClassMethods
|
52
60
|
#receiver.send :include, InstanceMethods
|
53
61
|
end
|
54
|
-
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Container
|
65
|
+
class << self
|
66
|
+
attr_accessor :runner
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
module Config
|
71
|
+
private
|
72
|
+
def use(runner)
|
73
|
+
Container.runner = runner
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
self.extend Config
|
data/lib/prepush_validator.rb
CHANGED
@@ -11,10 +11,10 @@ module PrePush
|
|
11
11
|
end
|
12
12
|
bin = File.dirname(__FILE__)
|
13
13
|
runners_dir = "#{bin}/../lib/runners"
|
14
|
-
found =
|
15
|
-
Dir.entries(runners_dir).each {|file| found = true if file == runner}
|
14
|
+
found = Dir.entries(runners_dir).any?{|file| file == "#{runner}.rb"}
|
16
15
|
unless found
|
17
|
-
|
16
|
+
all = Dir.entries(runners_dir).select{|f| !File.directory? f}.join(', ')
|
17
|
+
puts "Couldn't find test runner #{runner} in #{all}"
|
18
18
|
return false
|
19
19
|
end
|
20
20
|
return true
|
@@ -0,0 +1 @@
|
|
1
|
+
use 'mspec-clr4.exe'
|
@@ -0,0 +1 @@
|
|
1
|
+
use 'nunit-console.exe'
|
@@ -0,0 +1 @@
|
|
1
|
+
use 'xunit.console.exe'
|
data/spec/pre_push_spec.rb
CHANGED
@@ -5,12 +5,24 @@ class Dummy
|
|
5
5
|
include PrePush
|
6
6
|
end
|
7
7
|
|
8
|
+
class DummyClr2
|
9
|
+
@clr = 'clr2'
|
10
|
+
@solution = "solution/path/whammy"
|
11
|
+
include PrePush
|
12
|
+
end
|
13
|
+
|
14
|
+
class DummyClr666
|
15
|
+
@clr = 'clr666'
|
16
|
+
@solution = "solution/path/whammy"
|
17
|
+
include PrePush
|
18
|
+
end
|
19
|
+
|
8
20
|
class SetExeDummy
|
9
21
|
@solution = 'meh'
|
10
22
|
@runner_exe = 'bar.exe'
|
11
23
|
@test_runner = 'nunit262'
|
12
|
-
def self.
|
13
|
-
@runners_exes
|
24
|
+
def self.get_runners_exes
|
25
|
+
@runners_exes
|
14
26
|
end
|
15
27
|
def self.set_exes
|
16
28
|
self.build
|
@@ -29,6 +41,19 @@ describe PrePush do
|
|
29
41
|
Dummy.should_receive("system").with(/solution\/path\/whammy$/)
|
30
42
|
Dummy.build
|
31
43
|
end
|
44
|
+
it "should use clr4 msbuild when no clr specified" do
|
45
|
+
Dummy.should_receive("system").with(/^C:\/Windows\/Microsoft.NET\/Framework\/v4.0.30319/)
|
46
|
+
Dummy.build
|
47
|
+
end
|
48
|
+
it "should use clr2 msbuild when clr2 specified" do
|
49
|
+
DummyClr2.should_receive("system").with(/^C:\/Windows\/Microsoft.NET\/Framework\/v2.0.50727/)
|
50
|
+
DummyClr2.build
|
51
|
+
end
|
52
|
+
it "should exit when inexistent clr specified" do
|
53
|
+
DummyClr666.should_receive("puts").with('please assign clr2 or clr4 to @clr')
|
54
|
+
DummyClr666.should_receive("exit").with(1)
|
55
|
+
DummyClr666.build
|
56
|
+
end
|
32
57
|
end
|
33
58
|
describe 'run_tests' do
|
34
59
|
it 'should call system to run tests in specified assemblies' do
|
@@ -47,10 +72,13 @@ describe PrePush do
|
|
47
72
|
end
|
48
73
|
end
|
49
74
|
describe 'set_exes_cache' do
|
50
|
-
it 'should
|
75
|
+
it 'should set runners individually and uniquely' do
|
51
76
|
SetExeDummy.should_receive("system").with(/meh$/)
|
52
77
|
SetExeDummy.set_exes
|
53
|
-
|
78
|
+
subject = SetExeDummy.get_runners_exes
|
79
|
+
subject[subject.keys[0]].should_not == subject[subject.keys[1]]
|
80
|
+
subject[subject.keys[0]].should_not == subject[subject.keys[2]]
|
81
|
+
subject[subject.keys[1]].should_not == subject[subject.keys[2]]
|
54
82
|
end
|
55
83
|
end
|
56
84
|
end
|
@@ -17,13 +17,13 @@ module PrePush
|
|
17
17
|
it "should fail when runner not found" do
|
18
18
|
Dir.stub('exists?').with('.git').and_return(true)
|
19
19
|
Dir.stub('exists?').with('.git/hooks').and_return(true)
|
20
|
-
PrePush::Validator.should_receive('puts').with(
|
20
|
+
PrePush::Validator.should_receive('puts').with(/^Couldn't find test runner non-existant-runner/)
|
21
21
|
PrePush::Validator.validate('non-existant-runner').should be false
|
22
22
|
end
|
23
23
|
it "should validate when runner found" do
|
24
24
|
Dir.stub('exists?').with('.git').and_return(true)
|
25
25
|
Dir.stub('exists?').with('.git/hooks').and_return(true)
|
26
|
-
Dir.stub('entries').with(/lib\/runners$/).and_return(['existant-runner'])
|
26
|
+
Dir.stub('entries').with(/lib\/runners$/).and_return(['existant-runner.rb'])
|
27
27
|
PrePush::Validator.validate('existant-runner').should be true
|
28
28
|
end
|
29
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pre_push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05
|
12
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &19942908 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.3'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19942908
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &19958232 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19958232
|
36
36
|
description: adding a pre-push hook for git to compile & run tests
|
37
37
|
email:
|
38
38
|
- nievegoor@gmail.com
|
@@ -103,15 +103,15 @@ files:
|
|
103
103
|
- lib/runners/xunit191/xunit.runner.utility.dll
|
104
104
|
- lib/runners/xunit191/xunit.runner.utility.xml
|
105
105
|
- lib/runners/xunit191/xunit.xml
|
106
|
+
- lib/runners_config/mspec.rb
|
107
|
+
- lib/runners_config/nunit262.rb
|
108
|
+
- lib/runners_config/xunit191.rb
|
106
109
|
- lib/spec_helper.rb
|
107
110
|
- pre_push.gemspec
|
108
111
|
- spec/TestProj/TestProj.sln
|
109
|
-
- spec/TestProj/TestProj.suo
|
110
112
|
- spec/TestProj/TestProj/AllTests.cs
|
111
113
|
- spec/TestProj/TestProj/Properties/AssemblyInfo.cs
|
112
114
|
- spec/TestProj/TestProj/TestProj.csproj
|
113
|
-
- spec/TestProj/TestProj/TestProj.csproj.user
|
114
|
-
- spec/TestProj/TestProj/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
|
115
115
|
- spec/TestProj/TestProj/packages.config
|
116
116
|
- spec/TestProj/packages/Machine.Specifications.0.5.12/Machine.Specifications.0.5.12.nupkg
|
117
117
|
- spec/TestProj/packages/Machine.Specifications.0.5.12/Machine.Specifications.0.5.12.nuspec
|
@@ -207,12 +207,9 @@ summary: Add a pre-push git hook on any of your repos to build & run tests of yo
|
|
207
207
|
.net project.
|
208
208
|
test_files:
|
209
209
|
- spec/TestProj/TestProj.sln
|
210
|
-
- spec/TestProj/TestProj.suo
|
211
210
|
- spec/TestProj/TestProj/AllTests.cs
|
212
211
|
- spec/TestProj/TestProj/Properties/AssemblyInfo.cs
|
213
212
|
- spec/TestProj/TestProj/TestProj.csproj
|
214
|
-
- spec/TestProj/TestProj/TestProj.csproj.user
|
215
|
-
- spec/TestProj/TestProj/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
|
216
213
|
- spec/TestProj/TestProj/packages.config
|
217
214
|
- spec/TestProj/packages/Machine.Specifications.0.5.12/Machine.Specifications.0.5.12.nupkg
|
218
215
|
- spec/TestProj/packages/Machine.Specifications.0.5.12/Machine.Specifications.0.5.12.nuspec
|
Binary file
|
data/spec/TestProj/TestProj.suo
DELETED
Binary file
|