skipjack 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skipjack/fsharp.rb +8 -0
- data/lib/skipjack/version.rb +1 -1
- data/spec/lib/skipjack/fsharp_spec.rb +145 -121
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5fcc6d5aff0dad590340067dc7a1bd195ad41a5
|
4
|
+
data.tar.gz: 1ce0cb7e4b1ac954d416b6771a2fc0dc629f69b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 072b51ee79024a50ff7ff26e7b455c618da47cbed3a4959436bd5f2182310d789d4e6c312dd490ff3f37c3018b3324ec47eeae5da3473914422c802bf1fa050f
|
7
|
+
data.tar.gz: f7ffeba7239c2affe10da9d276a2b46130a89c4021c3e095ffa6b29e576df6c6b1f6907ab7d66db5081b75514c24b3d717a0852f3fc46ae5931e249148f184aa
|
data/lib/skipjack/fsharp.rb
CHANGED
@@ -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
|
data/lib/skipjack/version.rb
CHANGED
@@ -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
|
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
|
-
|
20
|
+
fsc "dummy.exe"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe "
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
24
|
+
describe "called executable" do
|
25
|
+
subject do
|
26
|
+
opts = invoke_fsc
|
27
|
+
opts.executable
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
|
-
|
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
|
-
|
40
|
-
|
34
|
+
context "when running on non-windows", windows: false do
|
35
|
+
it { should eq "fsharpc" }
|
36
|
+
end
|
37
|
+
end
|
41
38
|
|
42
|
-
|
43
|
-
|
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
|
-
|
47
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
66
|
+
context "resident set to true", resident: true do
|
67
|
+
it { should eq true }
|
68
|
+
end
|
59
69
|
|
60
|
-
|
70
|
+
context "resident set to false", resident: false do
|
71
|
+
it { should eq false }
|
61
72
|
end
|
73
|
+
end
|
62
74
|
|
63
|
-
|
75
|
+
describe "--target: argument" do
|
76
|
+
describe "output file is an .dll file" do
|
64
77
|
before do |ex|
|
65
|
-
@
|
66
|
-
t.
|
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 {
|
83
|
+
subject { @opts.target }
|
71
84
|
|
72
|
-
context "
|
73
|
-
it
|
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 "
|
79
|
-
it { should eq
|
89
|
+
context "when target = :library", target: :library do
|
90
|
+
it { should eq "library" }
|
80
91
|
end
|
81
92
|
|
82
|
-
context "
|
83
|
-
it { should eq
|
93
|
+
context "when target = :exe", target: :exe do
|
94
|
+
it { should eq "exe" }
|
84
95
|
end
|
85
96
|
end
|
86
97
|
|
87
|
-
describe "
|
98
|
+
describe "output file is an .exe file" do
|
88
99
|
before do |ex|
|
89
|
-
@
|
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 {
|
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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
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
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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.
|
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-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|