teapot 1.0.0.pre.rc9 → 1.0.0.pre.rc10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,52 +0,0 @@
1
- # Copyright, 2014, 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 'teapot/build'
22
- require 'teapot/environment'
23
-
24
- module Teapot::BuildSpec
25
- class DummyTarget
26
- def name
27
- "dummy-target"
28
- end
29
-
30
- def build
31
- lambda do
32
- # This is technically incorrect, because this Top graph node specifies no outputs. But, for testing, it's fine.
33
- fs.touch "bob"
34
- end
35
- end
36
- end
37
-
38
- describe Teapot::Build do
39
- let(:environment) {Teapot::Environment.hash(foo: 'bar')}
40
-
41
- it "should create a simple build graph" do
42
- expect(FileUtils::NoWrite).to receive(:touch).with("bob").once
43
- expect(FileUtils::Verbose).to receive(:touch).with("bob").once
44
-
45
- controller = Teapot::Build::Controller.new do |controller|
46
- controller.add_target(DummyTarget.new, environment)
47
- end
48
-
49
- controller.update!
50
- end
51
- end
52
- end
@@ -1,91 +0,0 @@
1
- # Copyright, 2012, 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 'teapot/environment'
22
-
23
- module Teapot::EnvironmentSpec
24
- describe Teapot::Environment do
25
- it "should chain environments together" do
26
- a = Teapot::Environment.new
27
- a[:cflags] = ["-std=c++11"]
28
-
29
- b = Teapot::Environment.new(a, {})
30
- b[:cflags] = ["-stdlib=libc++"]
31
- b[:rcflags] = lambda {cflags.reverse}
32
-
33
- expect(b.flatten.to_hash).to be == {:cflags => ["-std=c++11", "-stdlib=libc++"], :rcflags => ["-stdlib=libc++", "-std=c++11"]}
34
- end
35
-
36
- it "should resolve nested lambda" do
37
- a = Teapot::Environment.new do
38
- sdk "bob-2.6"
39
- cflags [->{"-sdk=#{sdk}"}]
40
- end
41
-
42
- b = Teapot::Environment.new(a) do
43
- sdk "bob-2.8"
44
- end
45
-
46
- c = Teapot::Environment.new(b) do
47
- cflags ["-pipe"]
48
- end
49
-
50
- expect(b.flatten.to_hash.keys.sort).to be == [:cflags, :sdk]
51
-
52
- expect(Teapot::Environment::System::convert_to_shell(b.flatten)).to be == {
53
- 'SDK' => "bob-2.8",
54
- 'CFLAGS' => "-sdk=bob-2.8"
55
- }
56
-
57
- expect(c.flatten[:cflags]).to be == %W{-sdk=bob-2.8 -pipe}
58
- end
59
-
60
- it "should combine environments" do
61
- a = Teapot::Environment.new(nil, {:name => 'a'})
62
- b = Teapot::Environment.new(a, {:name => 'b'})
63
- c = Teapot::Environment.new(nil, {:name => 'c'})
64
- d = Teapot::Environment.new(c, {:name => 'd'})
65
-
66
- top = Teapot::Environment.combine(b, d)
67
-
68
- expect(top.values).to be == d.values
69
- expect(top.parent.values).to be == c.values
70
- expect(top.parent.parent.values).to be == b.values
71
- expect(top.parent.parent.parent.values).to be == a.values
72
- end
73
-
74
- it "should combine defaults" do
75
- local = Teapot::Environment.new do
76
- architectures ["-m64"]
77
- end
78
-
79
- platform = Teapot::Environment.new do
80
- default architectures ["-arch", "i386"]
81
- end
82
-
83
- combined = Teapot::Environment.combine(
84
- platform,
85
- local
86
- )
87
-
88
- expect(combined[:architectures]).to be == ["-m64"]
89
- end
90
- end
91
- end
@@ -1,50 +0,0 @@
1
- # Copyright, 2012, 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 'teapot/name'
22
-
23
- module Teapot::NameSpec
24
- describe Teapot::Name do
25
- let(:name) {Teapot::Name.new('Foo Bar')}
26
- it "retains the original text" do
27
- expect(name.text).to be == 'Foo Bar'
28
- end
29
-
30
- it "should generate useful identifiers" do
31
- expect(name.identifier).to be == 'FooBar'
32
- end
33
-
34
- it "should generate useful target names" do
35
- expect(name.target).to be == 'foo-bar'
36
- end
37
-
38
- it "should generate useful macro names" do
39
- expect(name.macro).to be == 'FOO_BAR'
40
- end
41
-
42
- it "should generate useful macro names" do
43
- expect(name.macro).to be == 'FOO_BAR'
44
- end
45
-
46
- it "can be constructed from target name" do
47
- expect(Teapot::Name.from_target(name.target).text).to be == name.text
48
- end
49
- end
50
- end