rbuilder 0.0.1 → 0.0.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/Rakefile +3 -1
- data/conf/example.conf +4 -2
- data/rbuilder/build.rb +9 -1
- data/rbuilder/build_command.rb +46 -7
- data/rbuilder/build_configuration.rb +2 -2
- data/rbuilder/build_description.rb +8 -2
- data/rbuilder/source_control/svn.rb +3 -2
- data/tests/source_control/test_svn.rb +11 -1
- data/tests/test_build_command.rb +23 -2
- data/tests/test_build_configuration.rb +8 -0
- data/tests/test_build_description.rb +23 -9
- metadata +2 -2
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
Gem::manage_gems
|
3
3
|
require 'rake/gempackagetask'
|
4
|
+
NEXT_VERSION = "0.0.3"
|
5
|
+
|
4
6
|
|
5
7
|
desc 'Running all unit tests'
|
6
8
|
task :default => :test
|
@@ -25,7 +27,7 @@ require 'rake/gempackagetask'
|
|
25
27
|
|
26
28
|
spec = Gem::Specification.new do |s|
|
27
29
|
s.name = "rbuilder"
|
28
|
-
s.version =
|
30
|
+
s.version = NEXT_VERSION
|
29
31
|
s.author = "Rob Westgeest"
|
30
32
|
s.email = "rob.westgeest@gmail.com"
|
31
33
|
s.homepage = "http://notaresource.blogspot.com/rbuilder"
|
data/conf/example.conf
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
build '
|
1
|
+
# simple configuration
|
2
|
+
build '/some/dir/integration_tests/some_project', 'rake'
|
3
|
+
# configuration with aliased name
|
4
|
+
build '/some/dir/integration_tests/some_other_project', 'rake', 'archive name'
|
data/rbuilder/build.rb
CHANGED
@@ -44,7 +44,15 @@ class Build
|
|
44
44
|
def green?
|
45
45
|
status == BuildStatus.ok
|
46
46
|
end
|
47
|
+
|
48
|
+
def ==(other)
|
49
|
+
other.is_a?(Build) &&
|
50
|
+
self.reason == other.reason &&
|
51
|
+
self.archive == other.archive &&
|
52
|
+
self.build_command == other.build_command &&
|
53
|
+
self.working_dir == other.working_dir
|
54
|
+
end
|
47
55
|
|
48
|
-
|
56
|
+
protected
|
49
57
|
attr_reader :build_command, :working_dir, :building
|
50
58
|
end
|
data/rbuilder/build_command.rb
CHANGED
@@ -16,18 +16,57 @@ class BuildCommand
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run_command(build_result)
|
19
|
-
|
20
|
-
|
21
|
-
while !stdout.eof?
|
22
|
-
|
23
|
-
build_result
|
24
|
-
puts line
|
19
|
+
orig_stderr = $stderr.dup
|
20
|
+
run_process commandline do |stdout,stderr|
|
21
|
+
while !(stdout.eof? && stderr.eof?)
|
22
|
+
report(build_result, stdout)
|
23
|
+
report(build_result, stderr)
|
25
24
|
end
|
26
|
-
end
|
25
|
+
end
|
27
26
|
return $? == 0
|
28
27
|
end
|
29
28
|
|
30
29
|
private
|
30
|
+
def report(build_result,io)
|
31
|
+
unless io.eof?
|
32
|
+
line = io.readline
|
33
|
+
build_result.info(line)
|
34
|
+
puts line
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def run_process(*cmd)
|
39
|
+
outpipe = IO::pipe
|
40
|
+
errorpipe = IO::pipe
|
41
|
+
|
42
|
+
pid = fork{
|
43
|
+
# child
|
44
|
+
outpipe.first.close
|
45
|
+
STDOUT.reopen(outpipe.last)
|
46
|
+
outpipe.last.close
|
47
|
+
|
48
|
+
errorpipe.first.close
|
49
|
+
STDERR.reopen(errorpipe.last)
|
50
|
+
errorpipe.last.close
|
51
|
+
|
52
|
+
exec(*cmd)
|
53
|
+
exit!($?)
|
54
|
+
}
|
55
|
+
|
56
|
+
outpipe.last.close
|
57
|
+
errorpipe.last.close
|
58
|
+
Process.waitpid(pid)
|
59
|
+
pi = [outpipe.first, errorpipe.first]
|
60
|
+
if defined? yield
|
61
|
+
begin
|
62
|
+
return yield(*pi)
|
63
|
+
ensure
|
64
|
+
pi.each{|p| p.close unless p.closed?}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
pi
|
68
|
+
end
|
69
|
+
|
31
70
|
attr_reader :commandline
|
32
71
|
|
33
72
|
end
|
@@ -7,8 +7,8 @@ class BuildConfiguration
|
|
7
7
|
@builder = builder
|
8
8
|
end
|
9
9
|
|
10
|
-
def build(dir, command)
|
11
|
-
@builder.add_description BuildDescription.new(BuildCommand.new(command), SourceControl.svn(dir))
|
10
|
+
def build(dir, command, logical_name = nil)
|
11
|
+
@builder.add_description BuildDescription.new(BuildCommand.new(command), SourceControl.svn(dir), logical_name)
|
12
12
|
end
|
13
13
|
|
14
14
|
def from_text(text)
|
@@ -5,10 +5,11 @@ class BuildDescription
|
|
5
5
|
include Observable
|
6
6
|
attr_reader :builds
|
7
7
|
|
8
|
-
def initialize(build_command, source_control)
|
8
|
+
def initialize(build_command, source_control, archive_name = nil)
|
9
9
|
@build_command = build_command
|
10
10
|
@builds = []
|
11
11
|
@source_control = source_control
|
12
|
+
@archive_name = archive_name
|
12
13
|
end
|
13
14
|
|
14
15
|
def status
|
@@ -28,13 +29,18 @@ class BuildDescription
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def create_build(reason)
|
31
|
-
Build.new(build_command, working_dir, reason,
|
32
|
+
Build.new(build_command, working_dir, reason, archive_name)
|
32
33
|
end
|
33
34
|
|
34
35
|
def iterate
|
35
36
|
source_control.report_change_to(self)
|
36
37
|
end
|
37
38
|
|
39
|
+
def archive_name
|
40
|
+
@archive_name || source_control.archive
|
41
|
+
end
|
42
|
+
|
43
|
+
|
38
44
|
private
|
39
45
|
|
40
46
|
def working_dir
|
@@ -42,8 +42,9 @@ module SourceControl
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def strip_server(line)
|
45
|
-
return
|
46
|
-
return $2
|
45
|
+
return $2 if line =~ /(svn.*:\/\/[^\/]*\/)(.*)/
|
46
|
+
return $2 if line =~ /(file.*:\/\/[^\/]*\/)(.*)/
|
47
|
+
return line
|
47
48
|
end
|
48
49
|
|
49
50
|
def strip_trunk(line)
|
@@ -28,11 +28,21 @@ module SourceControl
|
|
28
28
|
assert_equal 'the_repo_root', svn.archive
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def test_archive_strips_server_and_trunk_if_protocol_is_svnssh
|
32
32
|
svn.stubs(:run_info).returns svn_output_for(:repo_root => 'svn+ssh://yosemite/home/svn/rbuilder/trunk')
|
33
33
|
assert_equal 'home/svn/rbuilder', svn.archive
|
34
34
|
end
|
35
35
|
|
36
|
+
def test_archive_strips_server_and_trunk_if_protocol_is_svn
|
37
|
+
svn.stubs(:run_info).returns svn_output_for(:repo_root => 'svn://yosemite/home/svn/rbuilder/trunk')
|
38
|
+
assert_equal 'home/svn/rbuilder', svn.archive
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_archive_strips_server_and_trunk_if_protocol_is_file
|
42
|
+
svn.stubs(:run_info).returns svn_output_for(:repo_root => 'file:///home/svn/rbuilder/trunk')
|
43
|
+
assert_equal 'home/svn/rbuilder', svn.archive
|
44
|
+
end
|
45
|
+
|
36
46
|
def test_info_returns_info_struct_with_revision_and_committer
|
37
47
|
svn.stubs(:run_info).returns svn_output_for(:author => 'westgeest', :revision => '1')
|
38
48
|
assert_equal Status.new(1, 'westgeest'), svn.get_info
|
data/tests/test_build_command.rb
CHANGED
@@ -35,7 +35,7 @@ class TestBuilderExecution < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
-
class
|
38
|
+
class TestBuildCommandWithRealCommandPrintingOnStdout < Test::Unit::TestCase
|
39
39
|
attr_reader :expected_output_lines, :build_command, :build_report
|
40
40
|
def setup
|
41
41
|
@expected_output_lines = ["line_1\n","line_2\n"]
|
@@ -54,4 +54,25 @@ class TestBuildCommandWithRealCommand < Test::Unit::TestCase
|
|
54
54
|
build_command.execute(".", build_report)
|
55
55
|
end
|
56
56
|
|
57
|
-
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class TestBuildCommandWithRealCommandPrintingOnStdErr < Test::Unit::TestCase
|
60
|
+
attr_reader :expected_output_lines, :build_command, :build_report
|
61
|
+
def setup
|
62
|
+
@expected_output_lines = ["line_1\n","line_2\n"]
|
63
|
+
@build_command = BuildCommand.new( %Q{ruby -e '$stderr.puts "line_1";$stderr.puts "line_2"; exit(1)'} )
|
64
|
+
@build_report = stub_everything
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_output_is_send_to_build_report
|
68
|
+
build_report.expects(:info).with("line_1\n")
|
69
|
+
build_report.expects(:info).with("line_2\n")
|
70
|
+
build_command.execute(".", build_report)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_real_abnormal_normal_command_should_be_red
|
74
|
+
build_report.expects :red
|
75
|
+
build_command.execute(".", build_report)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -15,6 +15,14 @@ class TestBuildConfiguration < Test::Unit::TestCase
|
|
15
15
|
assert_equal 1, builder.descriptions.size
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_build_creates_build_description_with_logical_name_if_passed
|
19
|
+
builder = Builder.new
|
20
|
+
config = BuildConfiguration.new(builder)
|
21
|
+
config.from_text("build '.', 'some_command', 'nice_name'")
|
22
|
+
assert_equal 'nice_name', builder.descriptions.first.archive_name
|
23
|
+
end
|
24
|
+
|
25
|
+
|
18
26
|
def test_build_fails_if_directory_does_not_exist
|
19
27
|
builder = Builder.new
|
20
28
|
config = BuildConfiguration.new(builder)
|
@@ -16,7 +16,7 @@ class TestBuildDescriptionIterate < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
class
|
19
|
+
class TestBuildDescription_RunABuild < Test::Unit::TestCase
|
20
20
|
attr_reader :working_dir, :build_command, :build_description, :build
|
21
21
|
def setup
|
22
22
|
@working_dir = "some_dir"
|
@@ -64,17 +64,31 @@ end
|
|
64
64
|
|
65
65
|
|
66
66
|
class TestBuildCreation < Test::Unit::TestCase
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
attr_reader :working_dir, :source_control, :build_command, :build_reason
|
68
|
+
def setup
|
69
|
+
@working_dir = "working_dir"
|
70
|
+
@source_control = stub(:working_dir => working_dir, :archive => 'the_archive')
|
71
|
+
@build_command = Object.new
|
72
|
+
@build_reason = Object.new
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_creates_a_build_with_a_build_descrition_reason_working_dir_and_build_report_and_source_control_archive
|
77
|
+
build_description = BuildDescription.new(build_command, source_control)
|
78
|
+
|
79
|
+
build = build_description.create_build(build_reason)
|
80
|
+
|
81
|
+
expected_build = Build.new(build_command, working_dir, build_reason, source_control.archive)
|
82
|
+
assert_equal expected_build, build
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_creates_a_build_with_a_build_descrition_reason_working_dir_and_build_report_and_logical_name
|
86
|
+
build_description = BuildDescription.new(build_command, source_control, 'the_logical_name' )
|
70
87
|
|
71
|
-
build_description = Object
|
72
|
-
build_reason = Object
|
73
|
-
build_description = BuildDescription.new(build_description, source_control)
|
74
88
|
build = build_description.create_build(build_reason)
|
75
89
|
|
76
|
-
|
77
|
-
assert_equal
|
90
|
+
expected_build = Build.new(build_command, working_dir, build_reason, 'the_logical_name')
|
91
|
+
assert_equal expected_build, build
|
78
92
|
end
|
79
93
|
end
|
80
94
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rbuilder
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2008-
|
6
|
+
version: 0.0.3
|
7
|
+
date: 2008-02-15 00:00:00 +01:00
|
8
8
|
summary: A Ruby auto build tool like build-o-matic for running on a desktop pc
|
9
9
|
require_paths:
|
10
10
|
- rbuilder
|