pre_push 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -3
- data/bin/prepush +11 -1
- data/lib/args_parser.rb +21 -0
- data/lib/pre_push/version.rb +1 -1
- data/lib/pre_push.rb +1 -0
- data/lib/template/pre-push +2 -2
- data/spec/args_parser_spec.rb +34 -0
- data/spec/pre_push_spec.rb +12 -6
- data/spec/spec_helper.rb +1 -0
- metadata +9 -6
data/README.md
CHANGED
@@ -24,11 +24,22 @@ After installing the gem, cd to the git repository you wish to add the hook to
|
|
24
24
|
(the directory containing a .git dir) and from there use one of the following:
|
25
25
|
|
26
26
|
$ prepush
|
27
|
-
$ prepush mspec
|
28
|
-
$ prepush xunit191
|
27
|
+
$ prepush /r=mspec
|
28
|
+
$ prepush /r=xunit191
|
29
29
|
|
30
30
|
the first will use nunit (2.6.2) for running your tests.
|
31
|
-
|
31
|
+
By default, the pre-push hook will use the first .sln file it finds.
|
32
|
+
|
33
|
+
The arguments accepted are:
|
34
|
+
|
35
|
+
/r={test runner}
|
36
|
+
/td={testable dlls}
|
37
|
+
|
38
|
+
If you wish to specify the dlls that your test runner should run/test use:
|
39
|
+
|
40
|
+
$ prepush /td=./path/to/some.dll,./path/to/another.dll
|
41
|
+
|
42
|
+
You can also modify the solution, dlls & even runner on the dropped pre-push file itself.
|
32
43
|
If you're using mspec, you may need to specify the dlls you wish to test in the @assemblies array variable. Failing to do so may result in the error "Could not load file or assembly 'path/to/your.sln' or one of its dependencies. The module was expected to contain an assembly manifest."
|
33
44
|
|
34
45
|
## Contributing
|
data/bin/prepush
CHANGED
@@ -3,10 +3,15 @@
|
|
3
3
|
require "pre_push"
|
4
4
|
require "prepush_validator"
|
5
5
|
require "sln_finder"
|
6
|
+
require "args_parser"
|
6
7
|
require "fileutils"
|
7
8
|
|
8
9
|
|
9
|
-
|
10
|
+
parsed_args = PrePush::ArgsParser.execute(ARGV)
|
11
|
+
runner = parsed_args[:runner]
|
12
|
+
test_dlls = parsed_args[:test_dlls]
|
13
|
+
assemblies_line = "@assemblies = {dtt} # insert dlls to test if different to the solution."
|
14
|
+
commented_assemblies_line = "# @assemblies = ['path/to/first/test.dll','path/to/second/test.dll'] # insert dlls to test if different to the solution."
|
10
15
|
|
11
16
|
if PrePush::Validator.validate(runner)
|
12
17
|
bin = File.dirname(__FILE__)
|
@@ -16,6 +21,11 @@ if PrePush::Validator.validate(runner)
|
|
16
21
|
file_text = File.read(pre_push_hook)
|
17
22
|
sln_path = PrePush::SlnFinder.find || "path/to/your.sln"
|
18
23
|
content = file_text.gsub(/\{runner\}/, "\"#{runner}\"").gsub(/\{sln_path\}/, "\"#{sln_path}\"")
|
24
|
+
if test_dlls != nil
|
25
|
+
content = content.gsub(/\{dtt\}/, "#{test_dlls}")
|
26
|
+
else
|
27
|
+
content = content.sub(assemblies_line, commented_assemblies_line)
|
28
|
+
end
|
19
29
|
File.open(pre_push_hook, "w") {|file| file.puts content}
|
20
30
|
puts "the pre-push hook has been dropped into your hooks dir; please modify it to build your assembly & run your tests."
|
21
31
|
end
|
data/lib/args_parser.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module PrePush
|
2
|
+
class ArgsParser
|
3
|
+
class << self
|
4
|
+
attr_accessor :args_props
|
5
|
+
ArgsParser.args_props = {'r' => [:runner, :str], 'td' => [:test_dlls, :array]}
|
6
|
+
end
|
7
|
+
def self.execute args
|
8
|
+
result = {:runner => 'nunit262'}
|
9
|
+
return result if args == nil
|
10
|
+
args_props.each_pair do |arg, prop|
|
11
|
+
current_parsed_arg = args.find {|a| a.start_with?("/#{arg}=")}
|
12
|
+
if current_parsed_arg != nil
|
13
|
+
value = current_parsed_arg.sub("/#{arg}=", "")
|
14
|
+
value = value.split(',') if prop[1] == :array
|
15
|
+
result[prop[0]] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
result
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/pre_push/version.rb
CHANGED
data/lib/pre_push.rb
CHANGED
data/lib/template/pre-push
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
require "pre_push"
|
4
4
|
|
5
5
|
class Executor
|
6
|
+
include PrePush
|
6
7
|
### change only if you change your test runner
|
7
8
|
@test_runner = {runner}
|
8
9
|
###
|
9
10
|
|
10
11
|
@solution = {sln_path} # the path to the solution to build
|
11
|
-
|
12
|
-
include PrePush
|
12
|
+
@assemblies = {dtt} # insert dlls to test if different to the solution.
|
13
13
|
end
|
14
14
|
|
15
15
|
Executor.run
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module PrePush
|
4
|
+
describe ArgsParser do
|
5
|
+
describe 'execute' do
|
6
|
+
describe "when no args provided" do
|
7
|
+
it "should return default" do
|
8
|
+
result = PrePush::ArgsParser.execute(nil)
|
9
|
+
result[:runner].should == "nunit262"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
describe "when /r is specfied" do
|
13
|
+
it "should parse value as a string" do
|
14
|
+
result = PrePush::ArgsParser.execute(["/r=mspec,invalid,data"])
|
15
|
+
result[:runner].should == "mspec,invalid,data"
|
16
|
+
end
|
17
|
+
it "should return a result with a runner" do
|
18
|
+
result = PrePush::ArgsParser.execute(["/r=mspec"])
|
19
|
+
result[:runner].should == "mspec"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe "when /td is specified" do
|
23
|
+
it "should parse value as an array" do
|
24
|
+
result = PrePush::ArgsParser.execute(["/td=./path/to/testable.dll"])
|
25
|
+
result[:test_dlls].should == ["./path/to/testable.dll"]
|
26
|
+
end
|
27
|
+
it "should return a result with multiple test dlls" do
|
28
|
+
result = PrePush::ArgsParser.execute(["/td=./path/to/testable.dll,./path/to/another.dll"])
|
29
|
+
result[:test_dlls].should == ["./path/to/testable.dll","./path/to/another.dll"]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/pre_push_spec.rb
CHANGED
@@ -5,14 +5,14 @@ class Dummy
|
|
5
5
|
include PrePush
|
6
6
|
end
|
7
7
|
|
8
|
-
class
|
9
|
-
@
|
10
|
-
@
|
8
|
+
class EmptyDllsDummy
|
9
|
+
@solution = "./path/to/some.sln"
|
10
|
+
@assemblies = []
|
11
11
|
include PrePush
|
12
12
|
end
|
13
13
|
|
14
|
-
class
|
15
|
-
@clr = '
|
14
|
+
class DummyClr2
|
15
|
+
@clr = 'clr2'
|
16
16
|
@solution = "solution/path/whammy"
|
17
17
|
include PrePush
|
18
18
|
end
|
@@ -47,10 +47,16 @@ describe PrePush do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
describe 'run_tests' do
|
50
|
-
it 'should call system to run tests
|
50
|
+
it 'should call system to run tests on specified assemblies' do
|
51
51
|
Dummy.should_receive("system").with(/some_test_proj.csproj/)
|
52
52
|
Dummy.run_tests(['some_test_proj.csproj'])
|
53
53
|
end
|
54
|
+
describe 'when assemblies are left empty' do
|
55
|
+
it 'should call system to run tests on solution' do
|
56
|
+
EmptyDllsDummy.should_receive("system").with(/\.\/path\/to\/some.sln"$/)
|
57
|
+
EmptyDllsDummy.run_tests([])
|
58
|
+
end
|
59
|
+
end
|
54
60
|
end
|
55
61
|
describe 'run' do
|
56
62
|
it 'should exit with code 1 when build or tests fail' do
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.0.5
|
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-06-
|
12
|
+
date: 2013-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &21424188 !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: *21424188
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &21423864 !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: *21423864
|
36
36
|
description: adding a pre-push hook for git to compile & run tests
|
37
37
|
email:
|
38
38
|
- nievegoor@gmail.com
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- README.md
|
48
48
|
- Rakefile
|
49
49
|
- bin/prepush
|
50
|
+
- lib/args_parser.rb
|
50
51
|
- lib/pre_push.rb
|
51
52
|
- lib/pre_push/version.rb
|
52
53
|
- lib/prepush_validator.rb
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- spec/TestProj/packages/xunit.1.9.1/lib/net20/xunit.xml
|
182
183
|
- spec/TestProj/packages/xunit.1.9.1/xunit.1.9.1.nupkg
|
183
184
|
- spec/TestProj/packages/xunit.1.9.1/xunit.1.9.1.nuspec
|
185
|
+
- spec/args_parser_spec.rb
|
184
186
|
- spec/mspec_integration_spec.rb
|
185
187
|
- spec/nunit_integration_spec.rb
|
186
188
|
- spec/pre_push_spec.rb
|
@@ -289,6 +291,7 @@ test_files:
|
|
289
291
|
- spec/TestProj/packages/xunit.1.9.1/lib/net20/xunit.xml
|
290
292
|
- spec/TestProj/packages/xunit.1.9.1/xunit.1.9.1.nupkg
|
291
293
|
- spec/TestProj/packages/xunit.1.9.1/xunit.1.9.1.nuspec
|
294
|
+
- spec/args_parser_spec.rb
|
292
295
|
- spec/mspec_integration_spec.rb
|
293
296
|
- spec/nunit_integration_spec.rb
|
294
297
|
- spec/pre_push_spec.rb
|