build-dependency 1.5.0 → 1.6.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/build/dependency/chain.rb +13 -22
  4. data/lib/build/dependency/partial_chain.rb +18 -21
  5. data/lib/build/dependency/provider.rb +28 -27
  6. data/lib/build/dependency/resolver.rb +12 -21
  7. data/lib/build/dependency/set.rb +27 -20
  8. data/lib/build/dependency/version.rb +7 -20
  9. data/lib/build/dependency/visualization.rb +59 -115
  10. data/lib/build/dependency.rb +9 -24
  11. data/license.md +21 -0
  12. data/readme.md +64 -0
  13. data/releases.md +5 -0
  14. data/test/build/dependency/chain.rb +223 -0
  15. data/test/build/dependency/partial_chain.rb +121 -0
  16. data/test/build/dependency/provider.rb +189 -0
  17. data/test/build/dependency/set.rb +122 -0
  18. data/test/build/dependency/visualization.rb +21 -0
  19. data/test/build/dependency/wildcard.rb +38 -0
  20. data.tar.gz.sig +1 -0
  21. metadata +49 -113
  22. metadata.gz.sig +0 -0
  23. data/.gitignore +0 -23
  24. data/.rspec +0 -4
  25. data/.travis.yml +0 -17
  26. data/Gemfile +0 -14
  27. data/Guardfile +0 -9
  28. data/README.md +0 -214
  29. data/Rakefile +0 -8
  30. data/build-dependency.gemspec +0 -24
  31. data/build_system_rules_and_algorithms.pdf +0 -0
  32. data/full.svg +0 -123
  33. data/partial.svg +0 -93
  34. data/spec/build/dependency/chain_spec.rb +0 -218
  35. data/spec/build/dependency/package.rb +0 -89
  36. data/spec/build/dependency/partial_chain_spec.rb +0 -119
  37. data/spec/build/dependency/provider_spec.rb +0 -123
  38. data/spec/build/dependency/set_spec.rb +0 -87
  39. data/spec/build/dependency/visualization_spec.rb +0 -33
  40. data/spec/build/dependency/wildcard_spec.rb +0 -45
  41. data/spec/spec_helper.rb +0 -11
  42. data/visualization.svg +0 -147
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- require_relative 'lib/build/dependency/version'
3
-
4
- Gem::Specification.new do |spec|
5
- spec.name = "build-dependency"
6
- spec.version = Build::Dependency::VERSION
7
- spec.authors = ["Samuel Williams"]
8
- spec.email = ["samuel.williams@oriontransfer.co.nz"]
9
- spec.summary = %q{A set of data structures and algorithms for dependency resolution.}
10
- spec.homepage = ""
11
- spec.license = "MIT"
12
-
13
- spec.files = `git ls-files -z`.split("\x0")
14
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
- spec.require_paths = ["lib"]
17
-
18
- spec.add_dependency "graphviz"
19
-
20
- spec.add_development_dependency "covered"
21
- spec.add_development_dependency "bundler"
22
- spec.add_development_dependency "rspec", "~> 3.6"
23
- spec.add_development_dependency "rake"
24
- end
Binary file
data/full.svg DELETED
@@ -1,123 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
- "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <!-- Generated by graphviz version 2.42.1 (0)
5
- -->
6
- <!-- Title: G Pages: 1 -->
7
- <svg width="354pt" height="404pt"
8
- viewBox="0.00 0.00 353.50 404.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
- <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 400)">
10
- <title>G</title>
11
- <polygon fill="white" stroke="transparent" points="-4,4 -4,-400 349.5,-400 349.5,4 -4,4"/>
12
- <!-- Variant/debug -->
13
- <g id="node1" class="node">
14
- <title>Variant/debug</title>
15
- <polygon fill="lightblue" stroke="black" stroke-width="2" points="114,-36 0,-36 0,0 114,0 114,-36"/>
16
- <text text-anchor="middle" x="57" y="-14.3" font-family="Monaco" font-size="14.00">Variant/debug</text>
17
- </g>
18
- <!-- variant -->
19
- <g id="node2" class="node">
20
- <title>variant</title>
21
- <polygon fill="lightgrey" stroke="black" points="89.5,-108 24.5,-108 24.5,-72 89.5,-72 89.5,-108"/>
22
- <text text-anchor="middle" x="57" y="-86.3" font-family="Monaco" font-size="14.00">variant</text>
23
- </g>
24
- <!-- variant&#45;&gt;Variant/debug -->
25
- <g id="edge1" class="edge">
26
- <title>variant&#45;&gt;Variant/debug</title>
27
- <path fill="none" stroke="black" d="M57,-71.7C57,-60.85 57,-46.92 57,-36.1"/>
28
- </g>
29
- <!-- Platform/linux -->
30
- <g id="node3" class="node">
31
- <title>Platform/linux</title>
32
- <polygon fill="lightblue" stroke="black" stroke-width="2" points="113.5,-180 0.5,-180 0.5,-144 113.5,-144 113.5,-180"/>
33
- <text text-anchor="middle" x="57" y="-158.3" font-family="Monaco" font-size="14.00">Platform/linux</text>
34
- </g>
35
- <!-- Platform/linux&#45;&gt;variant -->
36
- <g id="edge2" class="edge">
37
- <title>Platform/linux&#45;&gt;variant</title>
38
- <path fill="none" stroke="black" d="M57,-143.7C57,-135.98 57,-126.71 57,-118.11"/>
39
- <polygon fill="black" stroke="black" points="60.5,-118.1 57,-108.1 53.5,-118.1 60.5,-118.1"/>
40
- </g>
41
- <!-- platform -->
42
- <g id="node4" class="node">
43
- <title>platform</title>
44
- <polygon fill="lightgrey" stroke="black" points="94.5,-252 19.5,-252 19.5,-216 94.5,-216 94.5,-252"/>
45
- <text text-anchor="middle" x="57" y="-230.3" font-family="Monaco" font-size="14.00">platform</text>
46
- </g>
47
- <!-- platform&#45;&gt;Platform/linux -->
48
- <g id="edge3" class="edge">
49
- <title>platform&#45;&gt;Platform/linux</title>
50
- <path fill="none" stroke="black" d="M57,-215.7C57,-204.85 57,-190.92 57,-180.1"/>
51
- </g>
52
- <!-- Compiler/clang -->
53
- <g id="node5" class="node">
54
- <title>Compiler/clang</title>
55
- <polygon fill="lightblue" stroke="black" points="297.5,-180 176.5,-180 176.5,-144 297.5,-144 297.5,-180"/>
56
- <text text-anchor="middle" x="237" y="-158.3" font-family="Monaco" font-size="14.00">Compiler/clang</text>
57
- </g>
58
- <!-- Language/C++14 -->
59
- <g id="node6" class="node">
60
- <title>Language/C++14</title>
61
- <polygon fill="white" stroke="black" stroke-width="2" points="345.5,-324 204.5,-324 204.5,-288 345.5,-288 345.5,-324"/>
62
- <text text-anchor="middle" x="275" y="-302.3" font-family="Monaco" font-size="14.00">Language/C++14</text>
63
- </g>
64
- <!-- Language/C++14&#45;&gt;Compiler/clang -->
65
- <g id="edge4" class="edge">
66
- <title>Language/C++14&#45;&gt;Compiler/clang</title>
67
- <path fill="none" stroke="black" d="M274.33,-287.92C273.23,-269.75 270.39,-240.32 263,-216 259.19,-203.45 252.69,-190.2 247.14,-180.09"/>
68
- </g>
69
- <!-- Language/C++17 -->
70
- <g id="node7" class="node">
71
- <title>Language/C++17</title>
72
- <polygon fill="white" stroke="black" stroke-width="2" points="253.5,-252 112.5,-252 112.5,-216 253.5,-216 253.5,-252"/>
73
- <text text-anchor="middle" x="183" y="-230.3" font-family="Monaco" font-size="14.00">Language/C++17</text>
74
- </g>
75
- <!-- Language/C++17&#45;&gt;Compiler/clang -->
76
- <g id="edge5" class="edge">
77
- <title>Language/C++17&#45;&gt;Compiler/clang</title>
78
- <path fill="none" stroke="black" d="M196.35,-215.7C204.72,-204.85 215.46,-190.92 223.81,-180.1"/>
79
- </g>
80
- <!-- lib -->
81
- <g id="node8" class="node">
82
- <title>lib</title>
83
- <polygon fill="orange" stroke="black" stroke-width="2" points="179,-324 125,-324 125,-288 179,-288 179,-324"/>
84
- <text text-anchor="middle" x="152" y="-302.3" font-family="Monaco" font-size="14.00">lib</text>
85
- </g>
86
- <!-- lib&#45;&gt;platform -->
87
- <g id="edge6" class="edge">
88
- <title>lib&#45;&gt;platform</title>
89
- <path fill="none" stroke="#000000" stroke-opacity="0.372549" d="M128.52,-287.7C116.44,-278.8 101.55,-267.82 88.48,-258.2"/>
90
- <polygon fill="none" stroke="#000000" stroke-opacity="0.372549" points="90.34,-255.22 80.21,-252.1 86.19,-260.85 90.34,-255.22"/>
91
- </g>
92
- <!-- lib&#45;&gt;Language/C++17 -->
93
- <g id="edge7" class="edge">
94
- <title>lib&#45;&gt;Language/C++17</title>
95
- <path fill="none" stroke="#000000" stroke-opacity="0.372549" d="M159.66,-287.7C163.19,-279.73 167.46,-270.1 171.37,-261.26"/>
96
- <polygon fill="none" stroke="#000000" stroke-opacity="0.372549" points="174.58,-262.67 175.43,-252.1 168.18,-259.83 174.58,-262.67"/>
97
- </g>
98
- <!-- app -->
99
- <g id="node9" class="node">
100
- <title>app</title>
101
- <polygon fill="orange" stroke="black" stroke-width="2" points="179,-396 125,-396 125,-360 179,-360 179,-396"/>
102
- <text text-anchor="middle" x="152" y="-374.3" font-family="Monaco" font-size="14.00">app</text>
103
- </g>
104
- <!-- app&#45;&gt;platform -->
105
- <g id="edge9" class="edge">
106
- <title>app&#45;&gt;platform</title>
107
- <path fill="none" stroke="#000000" stroke-opacity="0.372549" d="M140.28,-359.85C133.22,-349.49 124.06,-336.01 116,-324 101.75,-302.76 85.72,-278.57 73.98,-260.77"/>
108
- <polygon fill="none" stroke="#000000" stroke-opacity="0.372549" points="76.68,-258.52 68.25,-252.1 70.84,-262.37 76.68,-258.52"/>
109
- </g>
110
- <!-- app&#45;&gt;Language/C++14 -->
111
- <g id="edge10" class="edge">
112
- <title>app&#45;&gt;Language/C++14</title>
113
- <path fill="none" stroke="#000000" stroke-opacity="0.372549" d="M179.3,-361.46C195.96,-351.98 217.54,-339.7 235.99,-329.2"/>
114
- <polygon fill="none" stroke="#000000" stroke-opacity="0.372549" points="237.8,-332.2 244.76,-324.21 234.34,-326.12 237.8,-332.2"/>
115
- </g>
116
- <!-- app&#45;&gt;lib -->
117
- <g id="edge8" class="edge">
118
- <title>app&#45;&gt;lib</title>
119
- <path fill="none" stroke="#000000" stroke-opacity="0.372549" d="M152,-359.7C152,-351.98 152,-342.71 152,-334.11"/>
120
- <polygon fill="none" stroke="#000000" stroke-opacity="0.372549" points="155.5,-334.1 152,-324.1 148.5,-334.1 155.5,-334.1"/>
121
- </g>
122
- </g>
123
- </svg>
data/partial.svg DELETED
@@ -1,93 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
- "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <!-- Generated by graphviz version 2.42.1 (0)
5
- -->
6
- <!-- Title: G Pages: 1 -->
7
- <svg width="463pt" height="332pt"
8
- viewBox="0.00 0.00 462.50 332.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
- <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 328)">
10
- <title>G</title>
11
- <polygon fill="white" stroke="transparent" points="-4,4 -4,-328 458.5,-328 458.5,4 -4,4"/>
12
- <!-- Variant/debug -->
13
- <g id="node1" class="node">
14
- <title>Variant/debug</title>
15
- <polygon fill="lightblue" stroke="black" stroke-width="2" points="114,-36 0,-36 0,0 114,0 114,-36"/>
16
- <text text-anchor="middle" x="57" y="-14.3" font-family="Monaco" font-size="14.00">Variant/debug</text>
17
- </g>
18
- <!-- variant -->
19
- <g id="node2" class="node">
20
- <title>variant</title>
21
- <polygon fill="lightgrey" stroke="black" points="89.5,-108 24.5,-108 24.5,-72 89.5,-72 89.5,-108"/>
22
- <text text-anchor="middle" x="57" y="-86.3" font-family="Monaco" font-size="14.00">variant</text>
23
- </g>
24
- <!-- variant&#45;&gt;Variant/debug -->
25
- <g id="edge1" class="edge">
26
- <title>variant&#45;&gt;Variant/debug</title>
27
- <path fill="none" stroke="black" d="M57,-71.7C57,-60.85 57,-46.92 57,-36.1"/>
28
- </g>
29
- <!-- Platform/linux -->
30
- <g id="node3" class="node">
31
- <title>Platform/linux</title>
32
- <polygon fill="lightblue" stroke="black" stroke-width="2" points="113.5,-180 0.5,-180 0.5,-144 113.5,-144 113.5,-180"/>
33
- <text text-anchor="middle" x="57" y="-158.3" font-family="Monaco" font-size="14.00">Platform/linux</text>
34
- </g>
35
- <!-- Platform/linux&#45;&gt;variant -->
36
- <g id="edge2" class="edge">
37
- <title>Platform/linux&#45;&gt;variant</title>
38
- <path fill="none" stroke="black" d="M57,-143.7C57,-135.98 57,-126.71 57,-118.11"/>
39
- <polygon fill="black" stroke="black" points="60.5,-118.1 57,-108.1 53.5,-118.1 60.5,-118.1"/>
40
- </g>
41
- <!-- platform -->
42
- <g id="node4" class="node">
43
- <title>platform</title>
44
- <polygon fill="lightgrey" stroke="black" points="94.5,-252 19.5,-252 19.5,-216 94.5,-216 94.5,-252"/>
45
- <text text-anchor="middle" x="57" y="-230.3" font-family="Monaco" font-size="14.00">platform</text>
46
- </g>
47
- <!-- platform&#45;&gt;Platform/linux -->
48
- <g id="edge3" class="edge">
49
- <title>platform&#45;&gt;Platform/linux</title>
50
- <path fill="none" stroke="black" d="M57,-215.7C57,-204.85 57,-190.92 57,-180.1"/>
51
- </g>
52
- <!-- lib -->
53
- <g id="node5" class="node">
54
- <title>lib</title>
55
- <polygon fill="orange" stroke="black" stroke-width="2" points="84,-324 30,-324 30,-288 84,-288 84,-324"/>
56
- <text text-anchor="middle" x="57" y="-302.3" font-family="Monaco" font-size="14.00">lib</text>
57
- </g>
58
- <!-- lib&#45;&gt;platform -->
59
- <g id="edge4" class="edge">
60
- <title>lib&#45;&gt;platform</title>
61
- <path fill="none" stroke="#000000" stroke-opacity="0.372549" d="M57,-287.7C57,-279.98 57,-270.71 57,-262.11"/>
62
- <polygon fill="none" stroke="#000000" stroke-opacity="0.372549" points="60.5,-262.1 57,-252.1 53.5,-262.1 60.5,-262.1"/>
63
- </g>
64
- <!-- Compiler/clang -->
65
- <g id="node6" class="node">
66
- <title>Compiler/clang</title>
67
- <polygon fill="lightblue" stroke="black" points="327.5,-180 206.5,-180 206.5,-144 327.5,-144 327.5,-180"/>
68
- <text text-anchor="middle" x="267" y="-158.3" font-family="Monaco" font-size="14.00">Compiler/clang</text>
69
- </g>
70
- <!-- Language/C++14 -->
71
- <g id="node7" class="node">
72
- <title>Language/C++14</title>
73
- <polygon fill="white" stroke="black" stroke-width="2" points="295.5,-252 154.5,-252 154.5,-216 295.5,-216 295.5,-252"/>
74
- <text text-anchor="middle" x="225" y="-230.3" font-family="Monaco" font-size="14.00">Language/C++14</text>
75
- </g>
76
- <!-- Language/C++14&#45;&gt;Compiler/clang -->
77
- <g id="edge5" class="edge">
78
- <title>Language/C++14&#45;&gt;Compiler/clang</title>
79
- <path fill="none" stroke="black" d="M235.38,-215.7C241.89,-204.85 250.25,-190.92 256.74,-180.1"/>
80
- </g>
81
- <!-- Language/C++17 -->
82
- <g id="node8" class="node">
83
- <title>Language/C++17</title>
84
- <polygon fill="white" stroke="black" points="454.5,-252 313.5,-252 313.5,-216 454.5,-216 454.5,-252"/>
85
- <text text-anchor="middle" x="384" y="-230.3" font-family="Monaco" font-size="14.00">Language/C++17</text>
86
- </g>
87
- <!-- Language/C++17&#45;&gt;Compiler/clang -->
88
- <g id="edge6" class="edge">
89
- <title>Language/C++17&#45;&gt;Compiler/clang</title>
90
- <path fill="none" stroke="black" d="M355.38,-215.88C337.25,-205.03 313.88,-191.05 295.73,-180.19"/>
91
- </g>
92
- </g>
93
- </svg>
@@ -1,218 +0,0 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative 'package'
22
-
23
- RSpec.describe Build::Dependency do
24
- describe "valid dependency resolution" do
25
- let(:a) do
26
- Package.new('apple-tree').tap do |package|
27
- package.provides 'apple' do
28
- fruit ['apple']
29
- end
30
- end
31
- end
32
-
33
- let(:b) do
34
- Package.new('orange-tree').tap do |package|
35
- package.provides 'orange' do
36
- fruit ['orange']
37
- end
38
- end
39
- end
40
-
41
- let(:c) do
42
- Package.new('blender').tap do |package|
43
- package.provides 'fruit-juice' do
44
- juice ['ice', 'cold']
45
- end
46
-
47
- package.depends 'apple'
48
- package.depends 'orange'
49
- end
50
- end
51
-
52
- it "should resolve direct dependency chain" do
53
- chain = Build::Dependency::Chain.expand(['fruit-juice'], [a, b, c])
54
- expect(chain.ordered.collect(&:provider)).to be == [a, b, c]
55
- expect(chain.unresolved).to be == []
56
- end
57
-
58
- it "should resolve wildcard dependency chain" do
59
- chain = Build::Dependency::Chain.expand(['fruit-*'], [a, b, c])
60
- expect(chain.ordered.collect(&:provider)).to be == [a, b, c]
61
- expect(chain.unresolved).to be == []
62
- end
63
-
64
- let(:d) do
65
- Package.new('bakery').tap do |package|
66
- package.provides 'pie'
67
- package.depends 'apple'
68
- end
69
- end
70
-
71
- it "shouldn't include unrelated units" do
72
- chain = Build::Dependency::Chain.expand(['pie'], [a, b, c, d])
73
-
74
- expect(chain.unresolved).to be == []
75
- expect(chain.ordered.collect(&:provider)).to be == [a, d]
76
- end
77
-
78
- it "should format nicely" do
79
- chain = Build::Dependency::Chain.expand(['fruit-juice'], [a, b, c])
80
- resolution = chain.ordered.first
81
- expect(resolution.to_s).to be == 'resolution "apple-tree" -> "apple"'
82
- end
83
- end
84
-
85
- describe "incomplete dependency resolution" do
86
- it "should report conflicts" do
87
- apple = Package.new('apple')
88
- apple.provides 'apple'
89
- apple.provides 'fruit'
90
-
91
- bananna = Package.new('bananna')
92
- bananna.provides 'fruit'
93
-
94
- salad = Package.new('salad')
95
- salad.depends 'fruit'
96
- salad.provides 'salad'
97
-
98
- chain = Build::Dependency::Chain.new(['salad'], [apple, bananna, salad])
99
- expect(chain.unresolved.first).to be == [Build::Dependency::Depends.new("fruit"), salad]
100
- expect(chain.conflicts).to be == {Build::Dependency::Depends.new("fruit") => [apple, bananna]}
101
-
102
- chain = Build::Dependency::Chain.new(['salad'], [apple, bananna, salad], ['apple'])
103
- expect(chain.unresolved).to be == []
104
- expect(chain.conflicts).to be == {}
105
- end
106
- end
107
-
108
- describe "multiple provisions" do
109
- let(:fruit) do
110
- Package.new('fruit').tap do |package|
111
- package.provides 'apple' do
112
- end
113
-
114
- package.provides 'orange' do
115
- end
116
- end
117
- end
118
-
119
- let(:salad) do
120
- Package.new('salad').tap do |package|
121
- package.depends 'apple'
122
- package.depends 'orange'
123
- package.provides 'salad'
124
- end
125
- end
126
-
127
- let(:lunch) do
128
- Package.new('lunch').tap do |package|
129
- package.depends 'apple'
130
- package.depends 'salad'
131
- package.provides 'lunch'
132
- end
133
- end
134
-
135
- let(:chain) {Build::Dependency::Chain.new(['lunch'], [fruit, salad, lunch])}
136
-
137
- it "should include both provisions" do
138
- expect(chain.provisions.count).to be == 4
139
- expect(chain.provisions.collect(&:name)).to be == ['apple', 'orange', 'salad', 'lunch']
140
- end
141
-
142
- it "should include both provisions in partial chain" do
143
- partial_chain = chain.partial(lunch)
144
- expect(partial_chain.provisions.count).to be == 3
145
- expect(partial_chain.provisions.collect(&:name)).to be == ['apple', 'orange', 'salad']
146
- end
147
- end
148
-
149
- it "should resolve aliases" do
150
- apple = Package.new('apple')
151
- apple.provides 'apple'
152
- apple.provides :fruit => 'apple'
153
-
154
- bananna = Package.new('bananna')
155
- bananna.provides 'bananna'
156
- bananna.provides :fruit => 'bananna'
157
-
158
- salad = Package.new('salad')
159
- salad.depends :fruit
160
- salad.provides 'salad'
161
-
162
- chain = Build::Dependency::Chain.expand(['salad'], [apple, bananna, salad], ['apple'])
163
- expect(chain.unresolved).to be == []
164
- expect(chain.conflicts).to be == {}
165
-
166
- expect(chain.ordered.size).to be == 2
167
- expect(chain.ordered[0].provider).to be == apple
168
- expect(chain.ordered[1].provider).to be == salad
169
- end
170
-
171
- it "should select dependencies with high priority" do
172
- bad_apple = Package.new('bad_apple')
173
- bad_apple.provides 'apple'
174
- bad_apple.priority = 20
175
-
176
- good_apple = Package.new('good_apple')
177
- good_apple.provides 'apple'
178
- good_apple.priority = 40
179
-
180
- chain = Build::Dependency::Chain.expand(['apple'], [bad_apple, good_apple])
181
-
182
- expect(chain.unresolved).to be == []
183
- expect(chain.conflicts).to be == {}
184
-
185
- # Should select higher priority package by default:
186
- expect(chain.ordered).to be == [good_apple.resolution_for(
187
- Build::Dependency::Depends['apple']
188
- )]
189
- end
190
-
191
- it "should expose direct dependencies" do
192
- system = Package.new('linux')
193
- system.provides 'linux'
194
- system.provides 'clang'
195
- system.provides system: 'linux'
196
- system.provides compiler: 'clang'
197
-
198
- library = Package.new('library')
199
- library.provides 'library'
200
- library.depends :system
201
- library.depends :compiler
202
-
203
- application = Package.new('application')
204
- application.provides 'application'
205
- application.depends :compiler
206
- application.depends 'library'
207
-
208
- chain = Build::Dependency::Chain.expand(['application'], [system, library, application])
209
-
210
- expect(chain.unresolved).to be == []
211
- expect(chain.conflicts).to be == {}
212
- expect(chain.ordered).to be == [
213
- system.resolution_for(Build::Dependency::Depends.new('clang')),
214
- library.resolution_for(Build::Dependency::Depends.new('library')),
215
- application.resolution_for(Build::Dependency::Depends.new('application')),
216
- ]
217
- end
218
- end
@@ -1,89 +0,0 @@
1
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require 'build/dependency'
22
-
23
- class Package
24
- include Build::Dependency
25
-
26
- def initialize(name = nil)
27
- @name = name
28
- end
29
-
30
- attr :name
31
-
32
- def inspect
33
- "<Package:#{@name}>"
34
- end
35
- end
36
-
37
- RSpec.shared_context "app packages" do
38
- let(:app) do
39
- Package.new('app').tap do |package|
40
- package.provides 'app'
41
- package.depends 'lib', private: true
42
- package.depends :platform, private: true
43
- package.depends 'Language/C++14', private: true
44
- end
45
- end
46
-
47
- let(:tests) do
48
- Package.new('tests').tap do |package|
49
- package.provides 'tests'
50
- package.depends 'lib', private: true
51
- package.depends :platform, private: true
52
- package.depends 'Language/C++17', private: true
53
- end
54
- end
55
-
56
- let(:lib) do
57
- Package.new('lib').tap do |package|
58
- package.provides 'lib'
59
- package.depends :platform, private: true
60
- package.depends 'Language/C++17', private: true
61
- end
62
- end
63
-
64
- let(:platform) do
65
- Package.new('Platform/linux').tap do |package|
66
- package.provides platform: 'Platform/linux'
67
- package.provides 'Platform/linux'
68
- package.depends :variant
69
- end
70
- end
71
-
72
- let(:variant) do
73
- Package.new('Variant/debug').tap do |package|
74
- package.provides variant: 'Variant/debug'
75
- package.provides 'Variant/debug'
76
- end
77
- end
78
-
79
- let(:compiler) do
80
- Package.new('Compiler/clang').tap do |package|
81
- package.provides 'Language/C++14'
82
- package.provides 'Language/C++17'
83
- end
84
- end
85
-
86
- let(:packages) {[app, tests, lib, platform, variant, compiler]}
87
-
88
- let(:visualization) {Build::Dependency::Visualization.new}
89
- end
@@ -1,119 +0,0 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative 'package'
22
-
23
- RSpec.describe Build::Dependency::PartialChain do
24
- describe "app chain" do
25
- include_context "app packages"
26
-
27
- let(:chain) {Build::Dependency::Chain.expand(['app', 'lib'], packages)}
28
-
29
- it "should generate full list of ordered providers" do
30
- expect(chain.ordered).to be == [
31
- variant.resolution_for(Build::Dependency::Depends.new('Variant/debug')),
32
- platform.resolution_for(Build::Dependency::Depends.new('Platform/linux')),
33
- compiler.resolution_for(Build::Dependency::Depends.new("Language/C++17", private: true)),
34
- lib.resolution_for(Build::Dependency::Depends.new('lib', private: true)),
35
- app.resolution_for(Build::Dependency::Depends.new('app')),
36
- ]
37
- end
38
-
39
- it "should generate a full list of provisions" do
40
- expect(chain.provisions).to be == [
41
- variant.provision_for(Build::Dependency::Depends.new('Variant/debug')),
42
- platform.provision_for(Build::Dependency::Depends.new('Platform/linux')),
43
- compiler.provision_for(Build::Dependency::Depends.new('Language/C++17', private: true)),
44
- lib.provision_for(Build::Dependency::Depends.new('lib', private: true)),
45
- compiler.provision_for(Build::Dependency::Depends.new('Language/C++14', private: true)),
46
- app.provision_for(Build::Dependency::Depends.new('app')),
47
- lib.provision_for(Build::Dependency::Depends.new('lib')),
48
- ]
49
-
50
- graph = visualization.generate(chain)
51
-
52
- Graphviz.output(graph, path: "full.svg", format: 'svg')
53
- end
54
-
55
- subject {described_class.new(chain, app.dependencies)}
56
-
57
- it "should select app packages" do
58
- expect(subject.ordered).to be == [
59
- variant.resolution_for(Build::Dependency::Depends.new('Variant/debug')),
60
- platform.resolution_for(Build::Dependency::Depends.new('Platform/linux')),
61
- lib.resolution_for(Build::Dependency::Depends.new('lib', private: true)),
62
- compiler.resolution_for(Build::Dependency::Depends.new("Language/C++14", private: true)),
63
- ]
64
-
65
- graph = visualization.generate(subject)
66
-
67
- Graphviz.output(graph, path: "partial.svg", format: 'svg')
68
- end
69
- end
70
-
71
- describe "private dependencies" do
72
- let(:a) do
73
- Package.new('a').tap do |package|
74
- package.provides 'a'
75
- end
76
- end
77
-
78
- let(:b) do
79
- Package.new('b').tap do |package|
80
- package.provides 'b'
81
- package.depends 'a', private: true
82
- end
83
- end
84
-
85
- let(:c) do
86
- Package.new('c').tap do |package|
87
- package.provides 'c'
88
- package.depends 'b'
89
- end
90
- end
91
-
92
- let(:d) do
93
- Package.new('d').tap do |package|
94
- package.provides 'd'
95
- package.depends 'c'
96
- end
97
- end
98
-
99
- let(:chain) {Build::Dependency::Chain.expand(['d'], [a, b, c, d])}
100
-
101
- it "should include direct private dependencies" do
102
- partial_chain = chain.partial(b)
103
-
104
- expect(partial_chain.ordered.collect(&:provider)).to be == [a]
105
- end
106
-
107
- it "shouldn't include nested private dependencies" do
108
- partial_chain = chain.partial(c)
109
-
110
- expect(partial_chain.ordered.collect(&:provider)).to be == [b]
111
- end
112
-
113
- it "should follow non-private dependencies" do
114
- partial_chain = chain.partial(d)
115
-
116
- expect(partial_chain.ordered.collect(&:provider)).to be == [b, c]
117
- end
118
- end
119
- end