build-graph 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/build-graph.gemspec +2 -2
- data/lib/build/graph/controller.rb +9 -4
- data/lib/build/graph/edge.rb +27 -12
- data/lib/build/graph/node.rb +41 -112
- data/lib/build/graph/task.rb +168 -0
- data/lib/build/graph/version.rb +1 -1
- data/lib/build/graph/walker.rb +109 -135
- data/spec/build/graph/graph_spec.rb +74 -103
- data/spec/build/graph/inherit_spec.rb +56 -0
- data/spec/build/graph/node_spec.rb +68 -0
- data/spec/build/graph/task_spec.rb +66 -0
- data/spec/build/graph/walker_spec.rb +93 -0
- metadata +15 -7
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'build/graph/walker'
|
23
|
+
require 'build/graph/task'
|
24
|
+
require 'build/files'
|
25
|
+
|
26
|
+
module Build::Graph::InheritSpec
|
27
|
+
include Build::Graph
|
28
|
+
include Build::Files
|
29
|
+
|
30
|
+
describe Build::Graph::Walker do
|
31
|
+
it "should inherit children outputs", :focus do
|
32
|
+
test_glob = Glob.new(__dir__, "*.rb")
|
33
|
+
listing_output = Paths.directory(__dir__, ["listing.txt"])
|
34
|
+
|
35
|
+
node_a = Node.new(Paths::NONE, :inherit, "a")
|
36
|
+
node_b = Node.new(test_glob, listing_output, "b")
|
37
|
+
|
38
|
+
walker = Walker.new do |walker, node|
|
39
|
+
task = Task.new(walker, node)
|
40
|
+
|
41
|
+
task.visit do
|
42
|
+
if node.process == 'a'
|
43
|
+
task.invoke(node_b)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
walker.update([node_a])
|
49
|
+
|
50
|
+
task_a = walker.tasks[node_a]
|
51
|
+
task_b = walker.tasks[node_b]
|
52
|
+
|
53
|
+
expect(task_a.outputs.to_a).to be == task_b.outputs.to_a
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'build/graph/node'
|
23
|
+
require 'build/files/glob'
|
24
|
+
require 'build/files/path/filesystem'
|
25
|
+
|
26
|
+
module Build::Graph::NodeSpec
|
27
|
+
include Build::Graph
|
28
|
+
include Build::Files
|
29
|
+
|
30
|
+
describe Build::Graph::Node do
|
31
|
+
it "should be unique" do
|
32
|
+
test_glob = Glob.new(__dir__, "*.rb")
|
33
|
+
listing_output = Paths.directory(__dir__, ["listing.txt"])
|
34
|
+
|
35
|
+
node_a = Node.new(test_glob, listing_output, "a")
|
36
|
+
node_b = Node.new(listing_output, Paths::NONE, "b")
|
37
|
+
|
38
|
+
expect(node_a).to be_eql node_a
|
39
|
+
expect(node_a).to_not be_eql node_b
|
40
|
+
|
41
|
+
node_c = Node.new(test_glob, listing_output, "a")
|
42
|
+
|
43
|
+
expect(node_a).to be_eql node_c
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be dirty" do
|
47
|
+
test_glob = Glob.new(__dir__, "*.rb")
|
48
|
+
listing_output = Paths.directory(__dir__, ["listing.txt"])
|
49
|
+
|
50
|
+
node_a = Node.new(test_glob, listing_output, "a")
|
51
|
+
|
52
|
+
expect(node_a.dirty?).to be true
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should be clean" do
|
56
|
+
test_glob = Glob.new(__dir__, "*.rb")
|
57
|
+
listing_output = Paths.directory(__dir__, ["listing.txt"])
|
58
|
+
|
59
|
+
listing_output.first.touch
|
60
|
+
|
61
|
+
node_a = Node.new(test_glob, listing_output, "a")
|
62
|
+
|
63
|
+
expect(node_a.dirty?).to be false
|
64
|
+
|
65
|
+
listing_output.first.delete
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'build/graph/node'
|
23
|
+
require 'build/graph/walker'
|
24
|
+
require 'build/graph/task'
|
25
|
+
require 'build/files/glob'
|
26
|
+
|
27
|
+
module Build::Graph::TaskSpec
|
28
|
+
include Build::Graph
|
29
|
+
include Build::Files
|
30
|
+
|
31
|
+
describe Build::Graph::Task do
|
32
|
+
it "should wait for children" do
|
33
|
+
node_a = Node.new(Paths::NONE, Paths::NONE, "a")
|
34
|
+
node_b = Node.new(Paths::NONE, Paths::NONE, "b")
|
35
|
+
|
36
|
+
nodes = Set.new([node_a])
|
37
|
+
|
38
|
+
sequence = []
|
39
|
+
|
40
|
+
# A walker runs repeatedly, updating tasks which have been marked as dirty.
|
41
|
+
walker = Walker.new do |walker, node|
|
42
|
+
task = Task.new(walker, node)
|
43
|
+
|
44
|
+
task.visit do
|
45
|
+
sequence << node.process.upcase
|
46
|
+
|
47
|
+
if node.process == 'a'
|
48
|
+
# This will invoke node_b concurrently, but as it is a child, task.visit won't finish until node_b is done.
|
49
|
+
task.invoke(node_b)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
sequence << node.process
|
54
|
+
end
|
55
|
+
|
56
|
+
walker.update(nodes)
|
57
|
+
|
58
|
+
expect(walker.tasks.count).to be == 2
|
59
|
+
expect(walker.failed_tasks.count).to be == 0
|
60
|
+
|
61
|
+
task_b = walker.tasks[node_b]
|
62
|
+
expect(walker.tasks[node_a].children).to be == [task_b]
|
63
|
+
expect(sequence).to be == ['A', 'B', 'b', 'a']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'build/graph/node'
|
23
|
+
require 'build/graph/walker'
|
24
|
+
require 'build/graph/task'
|
25
|
+
require 'build/files/glob'
|
26
|
+
|
27
|
+
module Build::Graph::WalkerSpec
|
28
|
+
include Build::Graph
|
29
|
+
include Build::Files
|
30
|
+
|
31
|
+
describe Build::Graph::Walker do
|
32
|
+
it "should be unique" do
|
33
|
+
test_glob = Glob.new(__dir__, "*.rb")
|
34
|
+
listing_output = Paths.directory(__dir__, ["listing.txt"])
|
35
|
+
|
36
|
+
node_a = Node.new(test_glob, listing_output, "a")
|
37
|
+
node_b = Node.new(listing_output, Paths::NONE, "b")
|
38
|
+
|
39
|
+
nodes = Set.new([node_a, node_b])
|
40
|
+
|
41
|
+
sequence = []
|
42
|
+
|
43
|
+
# A walker runs repeatedly, updating tasks which have been marked as dirty.
|
44
|
+
walker = Walker.new do |walker, node|
|
45
|
+
task = Task.new(walker, node)
|
46
|
+
|
47
|
+
task.visit do
|
48
|
+
sequence << node.process
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
walker.update(nodes)
|
53
|
+
|
54
|
+
expect(walker.tasks.count).to be == 2
|
55
|
+
expect(walker.failed_tasks.count).to be == 0
|
56
|
+
expect(sequence).to be == ['a', 'b']
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should cascade failure" do
|
60
|
+
test_glob = Glob.new(__dir__, "*.rb")
|
61
|
+
listing_output = Paths.directory(__dir__, ["listing.txt"])
|
62
|
+
summary_output = Paths.directory(__dir__, ["summary.txt"])
|
63
|
+
|
64
|
+
node_a = Node.new(test_glob, listing_output, "a")
|
65
|
+
node_b = Node.new(listing_output, summary_output, "b")
|
66
|
+
|
67
|
+
nodes = Set.new([node_a, node_b])
|
68
|
+
|
69
|
+
# A walker runs repeatedly, updating tasks which have been marked as dirty.
|
70
|
+
walker = Walker.new do |walker, node|
|
71
|
+
task = Task.new(walker, node)
|
72
|
+
|
73
|
+
task.visit do
|
74
|
+
if node.process == 'a'
|
75
|
+
raise TransientError.new('Test Failure')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
walker.update(nodes)
|
81
|
+
|
82
|
+
expect(walker.tasks.count).to be == 2
|
83
|
+
expect(walker.failed_tasks.count).to be == 2
|
84
|
+
expect(listing_output).to be_intersect walker.failed_outputs
|
85
|
+
expect(summary_output).to be_intersect walker.failed_outputs
|
86
|
+
|
87
|
+
walker.clear_failed
|
88
|
+
|
89
|
+
expect(walker.tasks.count).to be == 0
|
90
|
+
expect(walker.failed_tasks.count).to be == 0
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: process-group
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.3.
|
33
|
+
version: 0.3.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.3.
|
40
|
+
version: 0.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: system
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.3.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.3.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,14 +143,19 @@ files:
|
|
143
143
|
- lib/build/graph/edge.rb
|
144
144
|
- lib/build/graph/error.rb
|
145
145
|
- lib/build/graph/node.rb
|
146
|
+
- lib/build/graph/task.rb
|
146
147
|
- lib/build/graph/version.rb
|
147
148
|
- lib/build/graph/walker.rb
|
148
149
|
- spec/build/graph/graph_spec.rb
|
150
|
+
- spec/build/graph/inherit_spec.rb
|
151
|
+
- spec/build/graph/node_spec.rb
|
149
152
|
- spec/build/graph/program/Benchmark.cpp
|
150
153
|
- spec/build/graph/program/Benchmark.h
|
151
154
|
- spec/build/graph/program/DictionarySort.h
|
152
155
|
- spec/build/graph/program/ParallelMergeSort.h
|
153
156
|
- spec/build/graph/program/main.cpp
|
157
|
+
- spec/build/graph/task_spec.rb
|
158
|
+
- spec/build/graph/walker_spec.rb
|
154
159
|
homepage: ''
|
155
160
|
licenses:
|
156
161
|
- MIT
|
@@ -178,9 +183,12 @@ summary: Build::Graph is a framework for build systems, with specific functional
|
|
178
183
|
for dealing with file based processes.
|
179
184
|
test_files:
|
180
185
|
- spec/build/graph/graph_spec.rb
|
186
|
+
- spec/build/graph/inherit_spec.rb
|
187
|
+
- spec/build/graph/node_spec.rb
|
181
188
|
- spec/build/graph/program/Benchmark.cpp
|
182
189
|
- spec/build/graph/program/Benchmark.h
|
183
190
|
- spec/build/graph/program/DictionarySort.h
|
184
191
|
- spec/build/graph/program/ParallelMergeSort.h
|
185
192
|
- spec/build/graph/program/main.cpp
|
186
|
-
|
193
|
+
- spec/build/graph/task_spec.rb
|
194
|
+
- spec/build/graph/walker_spec.rb
|