|
1 | 1 | const tape = require('tape');
|
2 | 2 | const spawn = require('tape-spawn');
|
| 3 | +const path = require('path'); |
3 | 4 | const pkg = require('../package.json');
|
4 | 5 |
|
5 | 6 | tape('CLI', function (t) {
|
@@ -62,14 +63,58 @@ tape('CLI', function (t) {
|
62 | 63 | spt.end();
|
63 | 64 | });
|
64 | 65 |
|
65 |
| - t.test('no-base-path', function (st) { |
66 |
| - var spt = spawn(st, './solcjs --bin test/resources/importA.sol'); |
67 |
| - spt.stderr.match(/not found: File import callback not supported/); |
| 66 | + t.test('no base path', function (st) { |
| 67 | + var spt = spawn( |
| 68 | + st, |
| 69 | + './solcjs --bin ' + |
| 70 | + 'test/resources/importA.sol ' + |
| 71 | + './test/resources//importA.sol ' + |
| 72 | + path.resolve('test/resources/importA.sol') + ' ' + |
| 73 | + // Adding importB explicitly here should make compiler find it despite the lack of callback |
| 74 | + 'test/resources/importB.sol ' |
| 75 | + ); |
| 76 | + spt.stderr.empty(); |
| 77 | + spt.succeeds(); |
| 78 | + spt.end(); |
| 79 | + }); |
| 80 | + |
| 81 | + t.test('relative base path', function (st) { |
| 82 | + // NOTE: This and other base path tests rely on the relative ./importB.sol import in importA.sol. |
| 83 | + // If base path is not stripped correctly from all source paths below, they will not be found |
| 84 | + // by the import callback when it appends the base path back. |
| 85 | + var spt = spawn( |
| 86 | + st, |
| 87 | + './solcjs --bin --base-path test/resources ' + |
| 88 | + 'test/resources/importA.sol ' + |
| 89 | + './test/resources//importA.sol ' + |
| 90 | + path.resolve('test/resources/importA.sol') |
| 91 | + ); |
| 92 | + spt.stderr.empty(); |
| 93 | + spt.succeeds(); |
| 94 | + spt.end(); |
| 95 | + }); |
| 96 | + |
| 97 | + t.test('relative non canonical base path', function (st) { |
| 98 | + var spt = spawn( |
| 99 | + st, |
| 100 | + './solcjs --bin --base-path ./test/resources ' + |
| 101 | + 'test/resources/importA.sol ' + |
| 102 | + './test/resources//importA.sol ' + |
| 103 | + path.resolve('test/resources/importA.sol') |
| 104 | + ); |
| 105 | + spt.stderr.empty(); |
| 106 | + spt.succeeds(); |
68 | 107 | spt.end();
|
69 | 108 | });
|
70 | 109 |
|
71 |
| - t.test('base-path', function (st) { |
72 |
| - var spt = spawn(st, './solcjs --bin --base-path test/resources test/resources/importA.sol'); |
| 110 | + t.test('absolute base path', function (st) { |
| 111 | + var spt = spawn( |
| 112 | + st, |
| 113 | + './solcjs --bin --base-path ' + path.resolve('test/resources') + ' ' + |
| 114 | + 'test/resources/importA.sol ' + |
| 115 | + './test/resources//importA.sol ' + |
| 116 | + path.resolve('test/resources/importA.sol') |
| 117 | + ); |
73 | 118 | spt.stderr.empty();
|
74 | 119 | spt.succeeds();
|
75 | 120 | spt.end();
|
|
0 commit comments