Skip to content

Commit f73055c

Browse files
committed
Support running tests even if compileJSON is missing
1 parent 2dac8d7 commit f73055c

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

test/package.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ tape('Version and license', function (t) {
4848

4949
tape('Compilation', function (t) {
5050
t.test('single files can be compiled', function (st) {
51+
if (!solc.supportsSingle) {
52+
st.skip('Not supported by solc');
53+
st.end();
54+
return;
55+
}
5156
var output = solc.compile('contract x { function g() public {} }');
5257
st.ok('contracts' in output);
5358
var bytecode = getBytecode(output, '', 'x');
@@ -71,6 +76,11 @@ tape('Compilation', function (t) {
7176
});
7277

7378
t.test('invalid source code fails properly', function (st) {
79+
if (!solc.supportsSingle) {
80+
st.skip('Not supported by solc');
81+
st.end();
82+
return;
83+
}
7484
var output = solc.compile('contract x { this is an invalid contract }');
7585
if (semver.lt(solc.semver(), '0.1.4')) {
7686
st.ok(output.error.indexOf('Parser error: Expected identifier') !== -1);
@@ -104,6 +114,12 @@ tape('Compilation', function (t) {
104114
return;
105115
}
106116

117+
if (!solc.supportsMulti) {
118+
st.skip('Not supported by solc');
119+
st.end();
120+
return;
121+
}
122+
107123
var input = {
108124
'lib.sol': 'library L { function f() public returns (uint) { return 7; } }',
109125
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
@@ -146,6 +162,12 @@ tape('Compilation', function (t) {
146162
return;
147163
}
148164

165+
if (!solc.supportsImportCallback) {
166+
st.skip('Not supported by solc');
167+
st.end();
168+
return;
169+
}
170+
149171
var input = {
150172
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
151173
};
@@ -200,6 +222,12 @@ tape('Compilation', function (t) {
200222
return;
201223
}
202224

225+
if (!solc.supportsImportCallback) {
226+
st.skip('Not supported by solc');
227+
st.end();
228+
return;
229+
}
230+
203231
var input = {
204232
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
205233
};
@@ -229,6 +257,12 @@ tape('Compilation', function (t) {
229257
return;
230258
}
231259

260+
if (!solc.supportsImportCallback) {
261+
st.skip('Not supported by solc');
262+
st.end();
263+
return;
264+
}
265+
232266
var input = {
233267
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
234268
};
@@ -248,6 +282,12 @@ tape('Compilation', function (t) {
248282
return;
249283
}
250284

285+
if (!solc.supportsImportCallback) {
286+
st.skip('Not supported by solc');
287+
st.end();
288+
return;
289+
}
290+
251291
var input = {
252292
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
253293
};
@@ -264,6 +304,12 @@ tape('Compilation', function (t) {
264304
return;
265305
}
266306

307+
if (!solc.supportsImportCallback) {
308+
st.skip('Not supported by solc');
309+
st.end();
310+
return;
311+
}
312+
267313
var input = {
268314
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
269315
};
@@ -539,6 +585,11 @@ tape('Loading Legacy Versions', function (t) {
539585
st.end();
540586
return;
541587
}
588+
if (!solcSnapshot.supportsSingle) {
589+
st.skip('Not supported by solc');
590+
st.end();
591+
return;
592+
}
542593
var output = solcSnapshot.compile('contract x { function g() public {} }');
543594
st.ok(':x' in output.contracts);
544595
st.ok(output.contracts[':x'].bytecode.length > 0);

wrapper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ function setupMethods (soljson) {
233233
compile: compile,
234234
compileStandard: compileStandard,
235235
compileStandardWrapper: compileStandardWrapper,
236+
supportsSingle: compileJSON !== null,
236237
supportsMulti: compileJSONMulti !== null,
237238
supportsImportCallback: compileJSONCallback !== null,
238239
supportsStandard: compileStandard !== null,

0 commit comments

Comments
 (0)