Skip to content

Commit ea371fd

Browse files
committed
Cleanup generated binaries and abi files.
1 parent 05a1955 commit ea371fd

File tree

1 file changed

+66
-48
lines changed

1 file changed

+66
-48
lines changed

test/cli.ts

Lines changed: 66 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,107 @@
11
import tape from 'tape';
22
import spawn from 'tape-spawn';
3+
import rimraf from 'rimraf';
34
import * as path from 'path';
45
import solc from '../';
56

7+
const dist = path.resolve(__dirname, '..');
8+
const solcjs = path.join(dist, 'solc.js');
9+
10+
function clean () {
11+
rimraf.sync(`${dist}/*{.bin,.abi}`);
12+
}
13+
614
tape('CLI', function (t) {
715
t.test('--version', function (st) {
8-
const spt = spawn(st, './solc.js --version');
16+
const spt = spawn(st, `node ${solcjs} --version`);
917
spt.stdout.match(solc.version() + '\n');
1018
spt.stdout.match(/^\s*[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?\+commit\.[0-9a-f]+([a-zA-Z0-9.-]+)?\s*$/);
1119
spt.stderr.empty();
1220
spt.end();
1321
});
1422

1523
t.test('no parameters', function (st) {
16-
const spt = spawn(st, './solc.js');
24+
const spt = spawn(st, `node ${solcjs}`);
1725
spt.stderr.match(/^Must provide a file/);
1826
spt.end();
1927
});
2028

2129
t.test('no mode specified', function (st) {
22-
const spt = spawn(st, './solc.js test/resources/fixtureSmoke.sol');
30+
const spt = spawn(st, `node ${solcjs} test/resources/fixtureSmoke.sol`);
2331
spt.stderr.match(/^Invalid option selected/);
2432
spt.end();
2533
});
2634

2735
t.test('--bin', function (st) {
28-
const spt = spawn(st, './solc.js --bin test/resources/fixtureSmoke.sol');
36+
const spt = spawn(st, `node ${solcjs} --bin test/resources/fixtureSmoke.sol`);
2937
spt.stderr.empty();
3038
spt.succeeds();
3139
spt.end();
40+
st.teardown(() => { clean(); });
3241
});
3342

3443
t.test('--bin --optimize', function (st) {
35-
const spt = spawn(st, './solc.js --bin --optimize test/resources/fixtureSmoke.sol');
44+
const spt = spawn(st, `node ${solcjs} --bin --optimize test/resources/fixtureSmoke.sol`);
3645
spt.stderr.empty();
3746
spt.succeeds();
3847
spt.end();
48+
st.teardown(() => { clean(); });
3949
});
4050

4151
t.test('--bin --optimize-runs 666', function (st) {
42-
const spt = spawn(st, './solc.js --bin --optimize-runs 666 test/resources/fixtureSmoke.sol');
52+
const spt = spawn(st, `node ${solcjs} --bin --optimize-runs 666 test/resources/fixtureSmoke.sol`);
4353
spt.stderr.empty();
4454
spt.succeeds();
4555
spt.end();
56+
st.teardown(() => { clean(); });
4657
});
4758

4859
t.test('--bin --optimize-runs not-a-number', function (st) {
49-
const spt = spawn(st, './solc.js --bin --optimize-runs not-a-number test/resources/fixtureSmoke.sol');
60+
const spt = spawn(st, `node ${solcjs} --bin --optimize-runs not-a-number test/resources/fixtureSmoke.sol`);
5061
spt.stderr.match(/^error: option '--optimize-runs <optimize-runs>' argument 'not-a-number' is invalid/);
5162
spt.end();
5263
});
5364

5465
t.test('invalid file specified', function (st) {
55-
const spt = spawn(st, './solc.js --bin test/fileNotFound.sol');
66+
const spt = spawn(st, `node ${solcjs} --bin test/fileNotFound.sol`);
5667
spt.stderr.match(/^Error reading /);
5768
spt.end();
5869
});
5970

6071
t.test('incorrect source source', function (st) {
61-
const spt = spawn(st, './solc.js --bin test/resources/fixtureIncorrectSource.sol');
72+
const spt = spawn(st, `node ${solcjs} --bin test/resources/fixtureIncorrectSource.sol`);
6273
spt.stderr.match(/SyntaxError: Invalid pragma "contract"/);
6374
spt.end();
6475
});
6576

6677
t.test('--abi', function (st) {
67-
const spt = spawn(st, './solc.js --abi test/resources/fixtureSmoke.sol');
78+
const spt = spawn(st, `node ${solcjs} --abi test/resources/fixtureSmoke.sol`);
6879
spt.stderr.empty();
6980
spt.succeeds();
7081
spt.end();
82+
st.teardown(() => { clean(); });
7183
});
7284

7385
t.test('--bin --abi', function (st) {
74-
const spt = spawn(st, './solc.js --bin --abi test/resources/fixtureSmoke.sol');
86+
const spt = spawn(st, `node ${solcjs} --bin --abi test/resources/fixtureSmoke.sol`);
7587
spt.stderr.empty();
7688
spt.succeeds();
7789
spt.end();
90+
st.teardown(() => { clean(); });
7891
});
7992

8093
t.test('no base path', function (st) {
8194
const spt = spawn(
8295
st,
83-
'./solc.js --bin ' +
84-
'test/resources/importA.sol ' +
85-
'./test/resources//importA.sol ' +
86-
path.resolve('test/resources/importA.sol')
96+
`node ${solcjs} --bin \
97+
test/resources/importA.sol \
98+
./test/resources//importA.sol \
99+
${path.resolve('test/resources/importA.sol')}`
87100
);
88101
spt.stderr.empty();
89102
spt.succeeds();
90103
spt.end();
104+
st.teardown(() => { clean(); });
91105
});
92106

93107
t.test('relative base path', function (st) {
@@ -96,65 +110,69 @@ tape('CLI', function (t) {
96110
// by the import callback when it appends the base path back.
97111
const spt = spawn(
98112
st,
99-
'./solc.js --bin --base-path test/resources ' +
100-
'test/resources/importA.sol ' +
101-
'./test/resources//importA.sol ' +
102-
path.resolve('test/resources/importA.sol')
113+
`node ${solcjs} --bin --base-path test/resources \
114+
test/resources/importA.sol \
115+
./test/resources//importA.sol \
116+
${path.resolve('test/resources/importA.sol')}`
103117
);
104118
spt.stderr.empty();
105119
spt.succeeds();
106120
spt.end();
121+
st.teardown(() => { clean(); });
107122
});
108123

109124
t.test('relative non canonical base path', function (st) {
110125
const spt = spawn(
111126
st,
112-
'./solc.js --bin --base-path ./test/resources ' +
113-
'test/resources/importA.sol ' +
114-
'./test/resources//importA.sol ' +
115-
path.resolve('test/resources/importA.sol')
127+
`node ${solcjs} --bin --base-path ./test/resources \
128+
test/resources/importA.sol \
129+
./test/resources//importA.sol \
130+
${path.resolve('test/resources/importA.sol')}`
116131
);
117132
spt.stderr.empty();
118133
spt.succeeds();
119134
spt.end();
135+
st.teardown(() => { clean(); });
120136
});
121137

122138
t.test('absolute base path', function (st) {
123139
const spt = spawn(
124140
st,
125-
'./solc.js --bin --base-path ' + path.resolve('test/resources') + ' ' +
126-
'test/resources/importA.sol ' +
127-
'./test/resources//importA.sol ' +
128-
path.resolve('test/resources/importA.sol')
141+
`node ${solcjs} --bin --base-path ${path.resolve('test/resources')} \
142+
test/resources/importA.sol \
143+
./test/resources//importA.sol \
144+
${path.resolve('test/resources/importA.sol')}`
129145
);
130146
spt.stderr.empty();
131147
spt.succeeds();
132148
spt.end();
149+
st.teardown(() => { clean(); });
133150
});
134151

135152
t.test('include paths', function (st) {
136153
const spt = spawn(
137154
st,
138-
'./solc.js --bin ' +
139-
'test/resources/importCallback/base/contractB.sol ' +
140-
'test/resources/importCallback/includeA/libY.sol ' +
141-
'./test/resources/importCallback/includeA//libY.sol ' +
142-
path.resolve('test/resources/importCallback/includeA/libY.sol') + ' ' +
143-
'--base-path test/resources/importCallback/base ' +
144-
'--include-path test/resources/importCallback/includeA ' +
145-
'--include-path ' + path.resolve('test/resources/importCallback/includeB/')
155+
`node ${solcjs} --bin \
156+
test/resources/importCallback/base/contractB.sol \
157+
test/resources/importCallback/includeA/libY.sol \
158+
./test/resources/importCallback/includeA//libY.sol \
159+
${path.resolve('test/resources/importCallback/includeA/libY.sol')} \
160+
--base-path test/resources/importCallback/base \
161+
--include-path test/resources/importCallback/includeA \
162+
--include-path ${path.resolve('test/resources/importCallback/includeB/')}`
146163
);
147164
spt.stderr.empty();
148165
spt.succeeds();
149166
spt.end();
167+
st.teardown(() => { clean(); });
150168
});
151169

152170
t.test('include paths without base path', function (st) {
153171
const spt = spawn(
154172
st,
155-
'./solc.js --bin ' +
156-
'test/resources/importCallback/contractC.sol ' +
157-
'--include-path test/resources/importCallback/includeA'
173+
`node ${solcjs} --bin \
174+
test/resources/importCallback/contractC.sol \
175+
--include-path test/resources/importCallback/includeA`
158176
);
159177
spt.stderr.match(/--include-path option requires a non-empty base path\./);
160178
spt.fails();
@@ -164,10 +182,10 @@ tape('CLI', function (t) {
164182
t.test('empty include paths', function (st) {
165183
const spt = spawn(
166184
st,
167-
'./solc.js --bin ' +
168-
'test/resources/importCallback/contractC.sol ' +
169-
'--base-path test/resources/importCallback/base ' +
170-
'--include-path='
185+
`node ${solcjs} --bin \
186+
test/resources/importCallback/contractC.sol \
187+
--base-path test/resources/importCallback/base \
188+
--include-path=`
171189
);
172190
spt.stderr.match(/Empty values are not allowed in --include-path\./);
173191
spt.fails();
@@ -190,7 +208,7 @@ tape('CLI', function (t) {
190208
}
191209
}
192210
};
193-
const spt = spawn(st, './solc.js --standard-json');
211+
const spt = spawn(st, `node ${solcjs} --standard-json`);
194212
spt.stdin.setEncoding('utf-8');
195213
spt.stdin.write(JSON.stringify(input));
196214
spt.stdin.end();
@@ -219,7 +237,7 @@ tape('CLI', function (t) {
219237
}
220238
}
221239
};
222-
const spt = spawn(st, './solc.js --standard-json --base-path test/resources');
240+
const spt = spawn(st, `node ${solcjs} --standard-json --base-path test/resources`);
223241
spt.stdin.setEncoding('utf-8');
224242
spt.stdin.write(JSON.stringify(input));
225243
spt.stdin.end();
@@ -245,10 +263,10 @@ tape('CLI', function (t) {
245263
};
246264
const spt = spawn(
247265
st,
248-
'./solc.js --standard-json ' +
249-
'--base-path test/resources/importCallback/base ' +
250-
'--include-path test/resources/importCallback/includeA ' +
251-
'--include-path ' + path.resolve('test/resources/importCallback/includeB/')
266+
`node ${solcjs} --standard-json \
267+
--base-path test/resources/importCallback/base \
268+
--include-path test/resources/importCallback/includeA \
269+
--include-path ${path.resolve('test/resources/importCallback/includeB/')}`
252270
);
253271
spt.stdin.setEncoding('utf-8');
254272
spt.stdin.write(JSON.stringify(input));

0 commit comments

Comments
 (0)