diff --git a/src/commands/dataize.js b/src/commands/dataize.js index ac8f830..1dd6d68 100644 --- a/src/commands/dataize.js +++ b/src/commands/dataize.js @@ -32,15 +32,18 @@ const path = require('path'); * @param {Hash} opts - All options */ module.exports = function(obj, args, opts) { - spawn( - `java`, - [ - '-Dfile.encoding=UTF-8', - `-Xss${opts.stack}`, - '-jar', path.resolve(opts.target, 'eoc.jar'), - obj, - ...args, - ], - {stdio: 'inherit'} - ); + const params = [ + '-Dfile.encoding=UTF-8', + `-Xss${opts.stack}`, + '-jar', path.resolve(opts.target, 'eoc.jar'), + obj, + ...args, + ] + console.debug('+ java ' + params.join(' ')); + spawn('java', params, {stdio: 'inherit'}).on('close', (code) => { + if (code !== 0) { + console.error(`Java exited with #${code} code`); + process.exit(1); + } + }); }; diff --git a/test/commands/test_dataize.js b/test/commands/test_dataize.js index 7bf38b3..21fa1a5 100644 --- a/test/commands/test_dataize.js +++ b/test/commands/test_dataize.js @@ -31,29 +31,19 @@ describe('dataize', function() { it('runs a single executable .JAR and dataizes an object', function(done) { home = path.resolve('temp/test-run/simple'); fs.rmSync(home, {recursive: true, force: true}); - fs.mkdirSync(path.resolve(home, 'src'), {recursive: true}); + fs.mkdirSync(path.resolve(home, 'src/foo/bar'), {recursive: true}); fs.writeFileSync( - path.resolve(home, 'src/simple.eo'), + path.resolve(home, 'src/foo/bar/simple.eo'), [ '+package foo.bar', '+alias org.eolang.io.stdout', - '+alias org.eolang.txt.sprintf', - '+alias org.eolang.collections.list', '', - '[args...] > app', - ' seq > @', - ' reduced.', - ' list', - ' * 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10', - ' TRUE', - ' [a x]', - ' TRUE > @', - ' stdout', - ' sprintf "Hello, %s!" (args.at 0)', + '[args] > simple', + ' stdout "Hello, world!\\n" > @', ].join('\n') ); const stdout = runSync([ - 'dataize', 'foo.bar.app', 'Jeff', + 'dataize', 'foo.bar.simple', '--verbose', '--stack=64M', '--clean', @@ -62,7 +52,7 @@ describe('dataize', function() { '-s', path.resolve(home, 'src'), '-t', path.resolve(home, 'target'), ]); - assert(stdout.includes('Hello, Jeff!'), stdout); + assert(stdout.includes('Hello, world!'), stdout); assert(stdout.includes(`The directory ${path.resolve(home, 'target')} deleted`), stdout); assert(!fs.existsSync(path.resolve('../../mvnw/target'))); done();