skipjack 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cb9abf2582ba7c6272ee0a2e7e4e68fa1adfb66
4
- data.tar.gz: 7d2a1174d871fdd42b32eaf8919f3b920686e118
3
+ metadata.gz: d5fcc6d5aff0dad590340067dc7a1bd195ad41a5
4
+ data.tar.gz: 1ce0cb7e4b1ac954d416b6771a2fc0dc629f69b7
5
5
  SHA512:
6
- metadata.gz: 4ab0948f509da6eb6e54266e31292e9855ed0d51ae98eb2a1864ceb063dd2d1b36b32fffdbe88c268b4d3b498362c275011734881567e5573f67fcbadede3eeb
7
- data.tar.gz: 42a53aa73621cbe99a18135430411030106907f61a311bdc6bee7de3ff4c9807c69940c204b5975a75b88c4c9ab8b95fd0067ad3fe0a3d904f801add96e33987
6
+ metadata.gz: 072b51ee79024a50ff7ff26e7b455c618da47cbed3a4959436bd5f2182310d789d4e6c312dd490ff3f37c3018b3324ec47eeae5da3473914422c802bf1fa050f
7
+ data.tar.gz: f7ffeba7239c2affe10da9d276a2b46130a89c4021c3e095ffa6b29e576df6c6b1f6907ab7d66db5081b75514c24b3d717a0852f3fc46ae5931e249148f184aa
@@ -45,6 +45,13 @@ module Skipjack
45
45
  compiler = "fsharpc"
46
46
  end
47
47
 
48
+ target = self.target
49
+ case File.extname(t.name)
50
+ when ".exe"
51
+ target = :exe
52
+ when ".dll"
53
+ target = :library
54
+ end unless target
48
55
  opts = []
49
56
  opts << "--out:#{t.name}"
50
57
  opts << "--target:#{target.to_s}"
@@ -56,6 +63,7 @@ module Skipjack
56
63
  dir = File.dirname(t.name)
57
64
 
58
65
  cmd = "#{compiler} #{opts.join(" ")} #{source_files.join(" ")}"
66
+ puts cmd
59
67
  raise "Error executing command" unless Kernel.system cmd
60
68
  end
61
69
  file_task.enhance dependencies
@@ -1,3 +1,3 @@
1
1
  module Skipjack
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -14,84 +14,99 @@ describe 'fsharp' do
14
14
  allow(Kernel).to receive(:system).and_return true
15
15
  end
16
16
 
17
- context "when a task is not executed" do
17
+ context "when a task is not invoked" do
18
18
  it "does not call the system" do
19
19
  expect_no_system_call
20
- @task = fsc "dummy.exe"
20
+ fsc "dummy.exe"
21
21
  end
22
22
  end
23
23
 
24
- describe "command line args" do
25
- before :each do
26
- expect_compiler_call do |opts|
27
- @opts = opts
28
- end
24
+ describe "called executable" do
25
+ subject do
26
+ opts = invoke_fsc
27
+ opts.executable
29
28
  end
30
29
 
31
- let :options do
32
- task = fsc "dummy.exe" do |t|
33
- @setup.call(t) if @setup
34
- end
35
- task.invoke
36
- @opts
30
+ context "when running on windows", windows: true do
31
+ it { should eq "fsc" }
37
32
  end
38
33
 
39
- describe "called executable" do
40
- subject { options.executable }
34
+ context "when running on non-windows", windows: false do
35
+ it { should eq "fsharpc" }
36
+ end
37
+ end
41
38
 
42
- context "when running on windows", windows: true do
43
- it { should eq "fsc" }
39
+ describe "--reference: argument" do
40
+ before do |ex|
41
+ @opts = invoke_fsc do |t|
42
+ t.references = ["ref1.dll", "ref2.dll"]
44
43
  end
44
+ end
45
+
46
+ subject { @opts.references }
45
47
 
46
- context "when running on non-windows", windows: false do
47
- it { should eq "fsharpc" }
48
+ it { should eq ["ref1.dll", "ref2.dll"] }
49
+ end
50
+
51
+ describe "--resident" do
52
+ before do |ex|
53
+ @opts = invoke_fsc do |t|
54
+ t.resident = ex.metadata[:resident] unless ex.metadata[:resident].nil?
48
55
  end
49
56
  end
50
57
 
51
- describe "--reference: argument" do
52
- before do |ex|
53
- @setup = lambda do |t|
54
- t.references = ["ref1.dll", "ref2.dll"]
55
- end
58
+ subject { @opts.resident }
59
+
60
+ context "resident is not set" do
61
+ it "defaults to true" do
62
+ expect(subject).to eq true
56
63
  end
64
+ end
57
65
 
58
- subject { options.references }
66
+ context "resident set to true", resident: true do
67
+ it { should eq true }
68
+ end
59
69
 
60
- it { should eq ["ref1.dll", "ref2.dll"] }
70
+ context "resident set to false", resident: false do
71
+ it { should eq false }
61
72
  end
73
+ end
62
74
 
63
- describe "--resident" do
75
+ describe "--target: argument" do
76
+ describe "output file is an .dll file" do
64
77
  before do |ex|
65
- @setup = lambda do |t|
66
- t.resident = ex.metadata[:resident] unless ex.metadata[:resident].nil?
78
+ @opts = invoke_fsc "dummy.dll" do |t|
79
+ t.target = ex.metadata[:target] unless ex.metadata[:target].nil?
67
80
  end
68
81
  end
69
82
 
70
- subject { options.resident }
83
+ subject { @opts.target }
71
84
 
72
- context "resident is not set" do
73
- it "defaults to true" do
74
- expect(subject).to eq true
75
- end
85
+ context "when target not set" do
86
+ it { should eq "library" }
76
87
  end
77
88
 
78
- context "resident set to true", resident: true do
79
- it { should eq true }
89
+ context "when target = :library", target: :library do
90
+ it { should eq "library" }
80
91
  end
81
92
 
82
- context "resident set to false", resident: false do
83
- it { should eq false }
93
+ context "when target = :exe", target: :exe do
94
+ it { should eq "exe" }
84
95
  end
85
96
  end
86
97
 
87
- describe "--target: argument" do
98
+ describe "output file is an .exe file" do
88
99
  before do |ex|
89
- @setup = lambda do |t|
90
- t.target = ex.metadata[:target]
100
+ @opts = invoke_fsc "dummy.exe" do |t|
101
+ t.target = ex.metadata[:target] unless ex.metadata[:target].nil?
91
102
  end
92
103
  end
93
104
 
94
- subject { options.target }
105
+ subject { @opts.target }
106
+
107
+ context "when target not set" do
108
+ it { should eq "exe" }
109
+ end
95
110
 
96
111
  context "when target = :library", target: :library do
97
112
  it { should eq "library" }
@@ -101,100 +116,109 @@ describe 'fsharp' do
101
116
  it { should eq "exe" }
102
117
  end
103
118
  end
119
+ end
104
120
 
105
- describe "source files" do
106
- it "contains the passed sources" do
107
- sources = ["source1.fs", "source2.fs"]
108
- FileUtils.touch "source1.fs"
109
- FileUtils.touch "source2.fs"
110
- @setup = lambda do |t|
111
- t.source_files = sources
112
- end
113
- expect(options.source_files).to eq(sources)
121
+ describe "source files" do
122
+ it "contains the passed sources" do
123
+ sources = ["source1.fs", "source2.fs"]
124
+ FileUtils.touch "source1.fs"
125
+ FileUtils.touch "source2.fs"
126
+ @opts = invoke_fsc do |t|
127
+ t.source_files = sources
114
128
  end
129
+ expect(@opts.source_files).to eq(sources)
115
130
  end
131
+ end
116
132
 
117
- describe "output" do
118
- it "sets the output file" do
119
- task = fsc "f/p.exe" do |t|
120
- @setup.call(t) if @setup
121
- end
122
- task.invoke
123
- expect(@opts.out).to eq("f/p.exe")
124
- end
125
- end
126
-
127
- describe "build optimization" do
128
- context "build output is older than source files" do
129
- it "calls the compiler" do
130
- FileUtils.touch('./p.exe')
131
- FileUtils.touch('s.fs')
132
- task = fsc "p.exe" do |t|
133
- t.target = :exe
134
- t.source_files = ["s.fs"]
135
- end
136
- task.invoke
137
- expect(@opts).to_not be_nil
133
+ describe "output" do
134
+ it "sets the output file" do
135
+ @opts = invoke_fsc "f/p.exe" do |t|
136
+ end
137
+ expect(@opts.out).to eq("f/p.exe")
138
+ end
139
+ end
140
+
141
+ describe "build optimization" do
142
+ context "build output is older than source files" do
143
+ it "calls the compiler" do
144
+ FileUtils.touch('./p.exe')
145
+ FileUtils.touch('s.fs')
146
+ @opts = invoke_fsc "p.exe" do |t|
147
+ t.target = :exe
148
+ t.source_files = ["s.fs"]
138
149
  end
150
+ expect(@opts).to_not be_nil
139
151
  end
152
+ end
140
153
 
141
- context "build output is newer than source files" do
142
- it "does not call the compiler" do
143
- FileUtils.touch('s.fs')
144
- FileUtils.touch('./p.exe')
145
- task = fsc "p.exe" do |t|
146
- t.target = :exe
147
- t.source_files = ["s.fs"]
148
- end
149
- task.invoke
150
- expect(@opts).to be_nil
154
+ context "build output is newer than source files" do
155
+ it "does not call the compiler" do
156
+ FileUtils.touch('s.fs')
157
+ FileUtils.touch('./p.exe')
158
+ @opts = invoke_fsc "p.exe" do |t|
159
+ t.target = :exe
160
+ t.source_files = ["s.fs"]
151
161
  end
162
+ expect(@opts).to be_nil
163
+ end
164
+ end
165
+
166
+ it "does not copy the source file to the destination folder by default" do
167
+ FileUtils.mkdir('input', 'output')
168
+ FileUtils.touch('input/x.dll')
169
+ task = fsc "output/p.exe" do |t|
170
+ t.target = :exe
171
+ t.add_reference 'input/x.dll'
172
+ end
173
+ task.invoke
174
+ expect(File.file?('output/x.dll')).to be false
175
+ end
176
+
177
+ it "copies the source file to the destination folder" do
178
+ FileUtils.mkdir('input', 'output')
179
+ FileUtils.touch('input/x.dll')
180
+ task = fsc "output/p.exe" do |t|
181
+ t.target = :exe
182
+ t.add_reference 'input/x.dll', copy_local: true
152
183
  end
184
+ task.invoke
185
+ expect(File.file?('output/x.dll')).to be true
186
+ end
153
187
 
154
- it "does not copy the source file to the destination folder by default" do
155
- FileUtils.mkdir('input', 'output')
156
- FileUtils.touch('input/x.dll')
157
- task = fsc "output/p.exe" do |t|
158
- t.target = :exe
159
- t.add_reference 'input/x.dll'
160
- end
161
- task.invoke
162
- expect(File.file?('output/x.dll')).to be false
163
- end
164
-
165
- it "copies the source file to the destination folder" do
166
- FileUtils.mkdir('input', 'output')
167
- FileUtils.touch('input/x.dll')
168
- task = fsc "output/p.exe" do |t|
169
- t.target = :exe
170
- t.add_reference 'input/x.dll', copy_local: true
171
- end
172
- task.invoke
173
- expect(File.file?('output/x.dll')).to be true
174
- end
175
-
176
- it "doesnt copy if copy_local is false" do
177
- FileUtils.mkdir('output')
178
- FileUtils.touch('output/x.dll')
179
- task = fsc "output/p.exe" do |t|
180
- t.target = :exe
181
- t.add_reference 'input/x.dll', copy_local: false
182
- end
183
- task.invoke
184
- op = lambda { task.invoke }
185
- expect(op).to_not raise_error
188
+ it "doesnt copy if copy_local is false" do
189
+ FileUtils.mkdir('output')
190
+ FileUtils.touch('output/x.dll')
191
+ task = fsc "output/p.exe" do |t|
192
+ t.target = :exe
193
+ t.add_reference 'input/x.dll', copy_local: false
186
194
  end
195
+ task.invoke
196
+ op = lambda { task.invoke }
197
+ expect(op).to_not raise_error
187
198
  end
188
199
  end
200
+ end
189
201
 
190
- describe "target type" do
191
- it "fails when using invalid target option" do
192
- op = lambda do
193
- task = fsc "p.exe" do |t|
194
- t.target = :invalid_option
195
- end
202
+ describe "target type" do
203
+ it "fails when using invalid target option" do
204
+ op = lambda do
205
+ task = fsc "p.exe" do |t|
206
+ t.target = :invalid_option
196
207
  end
197
- expect(op).to raise_error(/^Invalid target/)
198
208
  end
209
+ expect(op).to raise_error(/^Invalid target/)
210
+ end
211
+ end
212
+
213
+ def invoke_fsc *args, &block
214
+ opts = nil
215
+ expect_compiler_call do |o|
216
+ opts = o
217
+ end
218
+ args = ["dummy.exe"] if args == []
219
+ task = fsc *args do |t|
220
+ yield t if block_given?
199
221
  end
222
+ task.invoke
223
+ opts
200
224
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skipjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Strøiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-09 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler