rscons 1.3.0 → 1.4.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.
@@ -140,7 +140,8 @@ module Rscons
140
140
  env.Program("a.out", "main.c")
141
141
 
142
142
  cache = "cache"
143
- Cache.should_receive(:new).and_return(cache)
143
+ Cache.should_receive(:instance).and_return(cache)
144
+ cache.should_receive(:clear_checksum_cache!)
144
145
  env.should_receive(:run_builder).with(anything, "a.out", ["main.c"], cache, {}).and_return(true)
145
146
  cache.should_receive(:write)
146
147
 
@@ -153,7 +154,8 @@ module Rscons
153
154
  env.Object("main.o", "other.cc")
154
155
 
155
156
  cache = "cache"
156
- Cache.should_receive(:new).and_return(cache)
157
+ Cache.should_receive(:instance).and_return(cache)
158
+ cache.should_receive(:clear_checksum_cache!)
157
159
  env.should_receive(:run_builder).with(anything, "main.o", ["other.cc"], cache, {}).and_return("main.o")
158
160
  env.should_receive(:run_builder).with(anything, "a.out", ["main.o"], cache, {}).and_return("a.out")
159
161
  cache.should_receive(:write)
@@ -167,12 +169,28 @@ module Rscons
167
169
  env.Object("main.o", "other.cc")
168
170
 
169
171
  cache = "cache"
170
- Cache.should_receive(:new).and_return(cache)
172
+ Cache.should_receive(:instance).and_return(cache)
173
+ cache.should_receive(:clear_checksum_cache!)
171
174
  env.should_receive(:run_builder).with(anything, "main.o", ["other.cc"], cache, {}).and_return(false)
172
175
  cache.should_receive(:write)
173
176
 
174
177
  expect { env.process }.to raise_error BuildError, /Failed.to.build.main.o/
175
178
  end
179
+
180
+ it "writes the cache when the Builder raises an exception" do
181
+ env = Environment.new
182
+ env.Object("module.o", "module.c")
183
+
184
+ cache = "cache"
185
+ Cache.should_receive(:instance).and_return(cache)
186
+ cache.should_receive(:clear_checksum_cache!)
187
+ env.stub(:run_builder) do |builder, target, sources, cache, vars|
188
+ raise "Ruby exception thrown by builder"
189
+ end
190
+ cache.should_receive(:write)
191
+
192
+ expect { env.process }.to raise_error RuntimeError, /Ruby exception thrown by builder/
193
+ end
176
194
  end
177
195
 
178
196
  describe "#clear_targets" do
@@ -249,8 +267,7 @@ module Rscons
249
267
  describe "#method_missing" do
250
268
  it "calls the original method missing when the target method is not a known builder" do
251
269
  env = Environment.new
252
- env.should_receive(:orig_method_missing).with(:foobar)
253
- env.foobar
270
+ expect {env.foobar}.to raise_error /undefined method .foobar./
254
271
  end
255
272
 
256
273
  it "records the target when the target method is a known builder" do
@@ -260,7 +277,7 @@ module Rscons
260
277
  target = env.instance_variable_get(:@targets)["target"]
261
278
  target.should_not be_nil
262
279
  target[:builder].is_a?(Builder).should be_true
263
- target[:source].should == ["src1", "src2"]
280
+ target[:sources].should == ["src1", "src2"]
264
281
  target[:vars].should == {var: "val"}
265
282
  target[:args].should == []
266
283
  end
@@ -1,6 +1,6 @@
1
1
  module Rscons
2
2
  describe VarSet do
3
- describe '.initialize' do
3
+ describe '#initialize' do
4
4
  it "initializes variables from a Hash" do
5
5
  v = VarSet.new({"one" => 1, "two" => :two})
6
6
  v["one"].should == 1
@@ -20,10 +20,10 @@ module Rscons
20
20
  end
21
21
  end
22
22
 
23
- describe :[] do
24
- v = VarSet.new({"fuz" => "a string", "foo" => 42, "bar" => :baz,
25
- "qax" => [3, 6], "qux" => {a: :b}})
23
+ describe "#[]" do
26
24
  it "allows accessing a variable with its verbatim value if type is not specified" do
25
+ v = VarSet.new({"fuz" => "a string", "foo" => 42, "bar" => :baz,
26
+ "qax" => [3, 6], "qux" => {a: :b}})
27
27
  v["fuz"].should == "a string"
28
28
  v["foo"].should == 42
29
29
  v["bar"].should == :baz
@@ -32,7 +32,7 @@ module Rscons
32
32
  end
33
33
  end
34
34
 
35
- describe :[]= do
35
+ describe "#[]=" do
36
36
  it "allows assigning to variables" do
37
37
  v = VarSet.new("CFLAGS" => ["-Wall", "-O3"])
38
38
  v["CPPPATH"] = ["one", "two"]
@@ -41,40 +41,86 @@ module Rscons
41
41
  end
42
42
  end
43
43
 
44
- describe '.append' do
44
+ describe "#include?" do
45
+ it "returns whether the variable is in the VarSet" do
46
+ v = VarSet.new("CFLAGS" => [], :foo => :bar)
47
+
48
+ expect(v.include?("CFLAGS")).to be_true
49
+ expect(v.include?(:CFLAGS)).to be_false
50
+ expect(v.include?(:foo)).to be_true
51
+ expect(v.include?("foo")).to be_false
52
+ expect(v.include?("bar")).to be_false
53
+
54
+ v2 = v.clone
55
+ v2.append("bar" => [])
56
+
57
+ expect(v2.include?("CFLAGS")).to be_true
58
+ expect(v2.include?(:CFLAGS)).to be_false
59
+ expect(v2.include?(:foo)).to be_true
60
+ expect(v2.include?("foo")).to be_false
61
+ expect(v2.include?("bar")).to be_true
62
+ end
63
+ end
64
+
65
+ describe '#append' do
45
66
  it "adds values from a Hash to the VarSet" do
46
67
  v = VarSet.new("LDFLAGS" => "-lgcc")
47
68
  v.append("LIBS" => "gcc", "LIBPATH" => ["mylibs"])
48
- v.vars.keys.should =~ ["LDFLAGS", "LIBS", "LIBPATH"]
69
+ expect(v["LDFLAGS"]).to eq("-lgcc")
70
+ expect(v["LIBS"]).to eq("gcc")
71
+ expect(v["LIBPATH"]).to eq(["mylibs"])
49
72
  end
73
+
50
74
  it "adds values from another VarSet to the VarSet" do
51
75
  v = VarSet.new("CPPPATH" => ["mydir"])
52
76
  v2 = VarSet.new("CFLAGS" => ["-O0"], "CPPPATH" => ["different_dir"])
53
77
  v.append(v2)
54
- v.vars.keys.should =~ ["CPPPATH", "CFLAGS"]
55
- v["CPPPATH"].should == ["different_dir"]
78
+ expect(v["CFLAGS"]).to eq(["-O0"])
79
+ expect(v["CPPPATH"]).to eq(["different_dir"])
80
+ end
81
+
82
+ it "does not pick up subsequent variable changes from a given VarSet" do
83
+ v = VarSet.new("dirs" => ["a"])
84
+ v2 = VarSet.new
85
+ v2.append(v)
86
+ v["dirs"] << "b"
87
+ expect(v["dirs"]).to eq(["a", "b"])
88
+ expect(v2["dirs"]).to eq(["a"])
56
89
  end
57
90
  end
58
91
 
59
- describe '.merge' do
92
+ describe '#merge' do
60
93
  it "returns a new VarSet merged with the given Hash" do
61
94
  v = VarSet.new("foo" => "yoda")
62
95
  v2 = v.merge("baz" => "qux")
63
- v.vars.keys.should == ["foo"]
64
- v2.vars.keys.should =~ ["foo", "baz"]
96
+ expect(v["foo"]).to eq("yoda")
97
+ expect(v2["foo"]).to eq("yoda")
98
+ expect(v2["baz"]).to eq("qux")
65
99
  end
100
+
66
101
  it "returns a new VarSet merged with the given VarSet" do
67
102
  v = VarSet.new("foo" => ["a", "b"], "bar" => 42)
68
103
  v2 = v.merge(VarSet.new("bar" => 33, "baz" => :baz))
69
104
  v2["foo"] << "c"
70
- v["foo"].should == ["a", "b"]
71
- v["bar"].should == 42
72
- v2["foo"].should == ["a", "b", "c"]
73
- v2["bar"].should == 33
105
+ expect(v["foo"]).to eq ["a", "b"]
106
+ expect(v["bar"]).to eq 42
107
+ expect(v2["foo"]).to eq ["a", "b", "c"]
108
+ expect(v2["bar"]).to eq 33
109
+ end
110
+
111
+ it "does not pick up subsequent variable changes from a given VarSet" do
112
+ v = VarSet.new("var" => ["a", "b"], "var2" => ["1", "2"])
113
+ v["var2"] << "3"
114
+ v2 = v.clone
115
+ v["var"] << "c"
116
+ expect(v["var"]).to eq(["a", "b", "c"])
117
+ expect(v["var2"]).to eq(["1", "2", "3"])
118
+ expect(v2["var"]).to eq(["a", "b"])
119
+ expect(v2["var2"]).to eq(["1", "2", "3"])
74
120
  end
75
121
  end
76
122
 
77
- describe '.expand_varref' do
123
+ describe '#expand_varref' do
78
124
  v = VarSet.new("CFLAGS" => ["-Wall", "-O2"],
79
125
  "CC" => "gcc",
80
126
  "CPPPATH" => ["dir1", "dir2"],
@@ -2,7 +2,7 @@ describe Rscons do
2
2
  describe ".clean" do
3
3
  it "removes all build targets and created directories" do
4
4
  cache = "cache"
5
- Rscons::Cache.should_receive(:new).and_return(cache)
5
+ Rscons::Cache.should_receive(:instance).and_return(cache)
6
6
  cache.should_receive(:targets).and_return(["build/a.out", "build/main.o"])
7
7
  FileUtils.should_receive(:rm_f).with("build/a.out")
8
8
  FileUtils.should_receive(:rm_f).with("build/main.o")
@@ -18,7 +18,7 @@ describe Rscons do
18
18
  Dir.should_receive(:rmdir).with("build")
19
19
  File.should_receive(:directory?).with("other").and_return(true)
20
20
  Dir.should_receive(:entries).with("other").and_return([".", "..", "other.file"])
21
- Rscons::Cache.should_receive(:clear)
21
+ cache.should_receive(:clear)
22
22
 
23
23
  Rscons.clean
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rscons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Holtrop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-25 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -166,8 +166,11 @@ files:
166
166
  - build_tests/two_sources/two.c
167
167
  - lib/rscons.rb
168
168
  - lib/rscons/builder.rb
169
+ - lib/rscons/builders/cfile.rb
170
+ - lib/rscons/builders/disassemble.rb
169
171
  - lib/rscons/builders/library.rb
170
172
  - lib/rscons/builders/object.rb
173
+ - lib/rscons/builders/preprocess.rb
171
174
  - lib/rscons/builders/program.rb
172
175
  - lib/rscons/cache.rb
173
176
  - lib/rscons/environment.rb
@@ -175,6 +178,7 @@ files:
175
178
  - lib/rscons/version.rb
176
179
  - rscons.gemspec
177
180
  - spec/build_tests_spec.rb
181
+ - spec/rscons/builders/cfile_spec.rb
178
182
  - spec/rscons/cache_spec.rb
179
183
  - spec/rscons/environment_spec.rb
180
184
  - spec/rscons/varset_spec.rb
@@ -206,6 +210,7 @@ specification_version: 4
206
210
  summary: Software construction library inspired by SCons and implemented in Ruby
207
211
  test_files:
208
212
  - spec/build_tests_spec.rb
213
+ - spec/rscons/builders/cfile_spec.rb
209
214
  - spec/rscons/cache_spec.rb
210
215
  - spec/rscons/environment_spec.rb
211
216
  - spec/rscons/varset_spec.rb