From fbc8fd8b7699af4636b04dc0e313eb3d7cec5423 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 25 Jul 2017 15:24:37 +0100 Subject: [PATCH 01/11] Fix --standard-json on solcjs --- solcjs | 5 +++-- test/cli.js | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/solcjs b/solcjs index 437cd2f5..58635af0 100755 --- a/solcjs +++ b/solcjs @@ -61,9 +61,10 @@ if (argv['standard-json']) { abort('Empty input was read'); } - var input = fs.readSync(process.stdin.fd, size)[0]; + var input = Buffer.alloc(size); + fs.readSync(process.stdin.fd, input, 0, size); - console.log(solc.compileStandard(input)); + console.log(solc.compileStandard(input.toString())); process.exit(0); } else if (files.length === 0) { console.error('Must provide a file'); diff --git a/test/cli.js b/test/cli.js index af12f32c..7ba6c7d2 100644 --- a/test/cli.js +++ b/test/cli.js @@ -56,4 +56,24 @@ tape('CLI', function (t) { spt.succeeds(); spt.end(); }); + + t.test('standard json', function (st) { + var input = { + 'language': 'Solidity', + 'sources': { + 'Contract.sol': { + 'content': 'pragma solidity ^0.4.0; contract Contract { function f() {} }' + } + } + }; + var spt = spawn(st, './solcjs --standard-json'); + spt.stdin.setEncoding('utf-8'); + spt.stdin.write(JSON.stringify(input)); + spt.stdin.end(); + spt.stderr.empty(); + spt.stdout.match(/Contract.sol/); + spt.stdout.match(/userdoc/); + spt.succeeds(); + spt.end(); + }); }); From f35f82336c90957c14c0563c8bf5414ca41d8739 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 25 Jul 2017 21:04:13 +0100 Subject: [PATCH 02/11] Wait until stdin piping finished --- test/cli.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/cli.js b/test/cli.js index 7ba6c7d2..f0d5c9ae 100644 --- a/test/cli.js +++ b/test/cli.js @@ -69,11 +69,13 @@ tape('CLI', function (t) { var spt = spawn(st, './solcjs --standard-json'); spt.stdin.setEncoding('utf-8'); spt.stdin.write(JSON.stringify(input)); - spt.stdin.end(); - spt.stderr.empty(); - spt.stdout.match(/Contract.sol/); - spt.stdout.match(/userdoc/); - spt.succeeds(); - spt.end(); + spt.stdin.pause(); + spt.stdin.on('finish', function () { + spt.stderr.empty(); + spt.stdout.match(/Contract.sol/); + spt.stdout.match(/userdoc/); + spt.succeeds(); + spt.end(); + }); }); }); From 197a2a66e7d2a1972552f10ab41e2c50d067befe Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 25 Sep 2017 13:55:44 +0100 Subject: [PATCH 03/11] Use stdin.end() in a timer and not stdin.pause() --- test/cli.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/cli.js b/test/cli.js index f0d5c9ae..4718c67e 100644 --- a/test/cli.js +++ b/test/cli.js @@ -70,6 +70,9 @@ tape('CLI', function (t) { spt.stdin.setEncoding('utf-8'); spt.stdin.write(JSON.stringify(input)); spt.stdin.pause(); + setTimeout(function () { + spt.stdin.end(); + }, 3000); spt.stdin.on('finish', function () { spt.stderr.empty(); spt.stdout.match(/Contract.sol/); From 4b0fef3d0754e1331b21e15079af5a3ec53ec207 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 27 Sep 2017 11:00:47 +0100 Subject: [PATCH 04/11] fix? --- test/cli.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/cli.js b/test/cli.js index 4718c67e..b38c3387 100644 --- a/test/cli.js +++ b/test/cli.js @@ -68,11 +68,8 @@ tape('CLI', function (t) { }; var spt = spawn(st, './solcjs --standard-json'); spt.stdin.setEncoding('utf-8'); - spt.stdin.write(JSON.stringify(input)); - spt.stdin.pause(); - setTimeout(function () { - spt.stdin.end(); - }, 3000); + // Write in one chunk. + spt.stdin.end(JSON.stringify(input)); spt.stdin.on('finish', function () { spt.stderr.empty(); spt.stdout.match(/Contract.sol/); From 760c31d0b3a76597b5d4462cb133db5726b12929 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 27 Sep 2017 11:06:42 +0100 Subject: [PATCH 05/11] ? --- test/cli.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/cli.js b/test/cli.js index b38c3387..d873ad40 100644 --- a/test/cli.js +++ b/test/cli.js @@ -68,9 +68,7 @@ tape('CLI', function (t) { }; var spt = spawn(st, './solcjs --standard-json'); spt.stdin.setEncoding('utf-8'); - // Write in one chunk. - spt.stdin.end(JSON.stringify(input)); - spt.stdin.on('finish', function () { + spt.stdin.write(JSON.stringify(input), function () { spt.stderr.empty(); spt.stdout.match(/Contract.sol/); spt.stdout.match(/userdoc/); From 5e76b291774eaa55a2ce8802b0f149fdf9eeebfc Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 29 Sep 2017 18:03:06 +0100 Subject: [PATCH 06/11] ?? --- test/cli.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/cli.js b/test/cli.js index d873ad40..cb806c76 100644 --- a/test/cli.js +++ b/test/cli.js @@ -68,7 +68,9 @@ tape('CLI', function (t) { }; var spt = spawn(st, './solcjs --standard-json'); spt.stdin.setEncoding('utf-8'); - spt.stdin.write(JSON.stringify(input), function () { + spt.stdin.write(JSON.stringify(input)); + spt.stdin.end(); + spt.stdin.on('finish', function () { spt.stderr.empty(); spt.stdout.match(/Contract.sol/); spt.stdout.match(/userdoc/); From 3fece60b512792b4cf3b72774902d01d116ff38d Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sat, 10 Feb 2018 16:27:21 +0000 Subject: [PATCH 07/11] Update test for latest solidity --- test/cli.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/cli.js b/test/cli.js index cb806c76..01f543da 100644 --- a/test/cli.js +++ b/test/cli.js @@ -60,9 +60,16 @@ tape('CLI', function (t) { t.test('standard json', function (st) { var input = { 'language': 'Solidity', + 'settings': { + 'outputSelection': { + '*': { + '*': [ 'evm.bytecode', 'userdoc' ] + } + } + }, 'sources': { 'Contract.sol': { - 'content': 'pragma solidity ^0.4.0; contract Contract { function f() {} }' + 'content': 'pragma solidity ^0.4.0; contract Contract { function f() pure public {} }' } } }; From 3014c6bc2156291a47b960f7a50025fc5f77c3cb Mon Sep 17 00:00:00 2001 From: Alex T Date: Wed, 20 Jun 2018 14:34:26 +0300 Subject: [PATCH 08/11] trigger build --- solcjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solcjs b/solcjs index 58635af0..05baa0a8 100755 --- a/solcjs +++ b/solcjs @@ -52,7 +52,7 @@ function abort (msg) { if (argv['standard-json']) { if (!solc.supportsStandard) { - abort('Compiler does not support Standard JSON I/O'); + abort('Compiler does not support Standard JSON I/O!'); } var size = fs.fstatSync(process.stdin.fd).size; From 2c9b86ba18ed781759a0e43dae06eb9f71a99e95 Mon Sep 17 00:00:00 2001 From: Alex T Date: Wed, 20 Jun 2018 15:03:07 +0300 Subject: [PATCH 09/11] trigger build --- solcjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/solcjs b/solcjs index 05baa0a8..1dbcfe17 100755 --- a/solcjs +++ b/solcjs @@ -55,7 +55,7 @@ if (argv['standard-json']) { abort('Compiler does not support Standard JSON I/O!'); } - var size = fs.fstatSync(process.stdin.fd).size; + /*var size = fs.fstatSync(process.stdin.fd).size; if (size <= 0) { abort('Empty input was read'); @@ -63,8 +63,9 @@ if (argv['standard-json']) { var input = Buffer.alloc(size); fs.readSync(process.stdin.fd, input, 0, size); - - console.log(solc.compileStandard(input.toString())); +*/ + var stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0 + console.log(solc.compileStandard(stdinBuffer.toString())); process.exit(0); } else if (files.length === 0) { console.error('Must provide a file'); From 7a5adb47ac2843139778c0861ab11a86a0687155 Mon Sep 17 00:00:00 2001 From: Alex T Date: Wed, 20 Jun 2018 15:04:12 +0300 Subject: [PATCH 10/11] build for branch as well --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 426a3068..1415a097 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,11 @@ node_js: - '8' - '6' - '4' -branches: +#branches: # We need to whitelist the branches which we want to have "push" automation. # Pull request automation is not constrained to this set of branches. - only: - - master +# only: +# - master matrix: fast_finish: true include: From 6458e1a4780d8e14895d098a5ca3150763c1c9fb Mon Sep 17 00:00:00 2001 From: Alex T Date: Thu, 21 Jun 2018 07:14:05 +0300 Subject: [PATCH 11/11] cleanup, build this branch as well --- .travis.yml | 7 ++++--- solcjs | 10 +--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1415a097..25376d75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,12 @@ node_js: - '8' - '6' - '4' -#branches: +branches: # We need to whitelist the branches which we want to have "push" automation. # Pull request automation is not constrained to this set of branches. -# only: -# - master + only: + - master + - solcjs-standard matrix: fast_finish: true include: diff --git a/solcjs b/solcjs index 1dbcfe17..aa577286 100755 --- a/solcjs +++ b/solcjs @@ -55,15 +55,7 @@ if (argv['standard-json']) { abort('Compiler does not support Standard JSON I/O!'); } - /*var size = fs.fstatSync(process.stdin.fd).size; - - if (size <= 0) { - abort('Empty input was read'); - } - - var input = Buffer.alloc(size); - fs.readSync(process.stdin.fd, input, 0, size); -*/ + // this locks until end of stdin is signaled with ctrl+D , works fine for piped stuff var stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0 console.log(solc.compileStandard(stdinBuffer.toString())); process.exit(0);