Skip to content

Commit

Permalink
#205: dataize works
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 22, 2023
1 parent 2634ad4 commit ec64572
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
25 changes: 14 additions & 11 deletions src/commands/dataize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};
22 changes: 6 additions & 16 deletions test/commands/test_dataize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
Expand Down

0 comments on commit ec64572

Please sign in to comment.