Skip to content

Commit

Permalink
#205: clean
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 22, 2023
1 parent beac1c7 commit a3607b3
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"mocha": "10.2.0"
},
"scripts": {
"test": "mocha --timeout 1200000"
"test": "mocha --timeout 1200000 --files test/**/*.js"
}
}
2 changes: 1 addition & 1 deletion src/commands/dataize.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = function(obj, args, opts) {
'-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) {
Expand Down
1 change: 1 addition & 0 deletions src/eoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ program.command('transpile')
if (program.opts().alone == undefined) {
register(program.opts())
.then((r) => assemble(program.opts()))
.then((r) => verify(program.opts()))
.then((r) => transpile(program.opts()));
} else {
transpile(program.opts());
Expand Down
8 changes: 4 additions & 4 deletions test/commands/test_assemble.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('assemble', function() {
home = path.resolve('temp/test-assemble/simple');
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'src'), {recursive: true});
fs.writeFileSync(path.resolve(home, 'src/simple.eo'), '[] > simple\n');
fs.writeFileSync(path.resolve(home, 'src/assemble.eo'), '[] > assemble\n');
const stdout = runSync([
'assemble',
'--verbose',
Expand All @@ -46,9 +46,9 @@ describe('assemble', function() {
stdout, home,
[
'target/eo-foreign.json',
'target/1-parse/simple.xmir',
'target/2-optimization-steps/simple',
'target/2-optimize/simple.xmir',
'target/1-parse/assemble.xmir',
'target/2-optimization-steps/assemble',
'target/2-optimize/assemble.xmir',
]
);
assert(!fs.existsSync(path.resolve('../../mvnw/target')));
Expand Down
2 changes: 1 addition & 1 deletion test/commands/test_clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('clean', function() {
fs.rmSync(eo, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'src'), {recursive: true});
fs.mkdirSync(eo, {recursive: true});
fs.writeFileSync(path.resolve(home, 'src/simple.eo'), '[] > simple\n');
fs.writeFileSync(path.resolve(home, 'src/clean.eo'), '[] > clean\n');
const stdout = runSync([
'clean', '-s', path.resolve(home, 'src'), '-t', path.resolve(home, 'target'), '--cached',
]);
Expand Down
21 changes: 11 additions & 10 deletions test/commands/test_compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('compile', function() {
home = path.resolve('temp/test-compile/simple');
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'src'), {recursive: true});
fs.writeFileSync(path.resolve(home, 'src/simple.eo'), simple());
fs.writeFileSync(path.resolve(home, 'src/compile.eo'), simple('compile'));
const stdout = runSync([
'compile',
'--parser=0.34.1',
Expand All @@ -43,9 +43,9 @@ describe('compile', function() {
assertFilesExist(
stdout, home,
[
'target/generated-sources/EOfoo/EObar/EOapp.java',
'target/generated-sources/EOfoo/EObar/EOcompile.java',
'target/generated-sources/EOorg/EOeolang/EObytes.java',
'target/classes/EOfoo/EObar/EOapp.class',
'target/classes/EOfoo/EObar/EOcompile.class',
'target/classes/org/eolang/Phi.class',
'target/classes/EOorg/EOeolang/EOint.class',
]
Expand All @@ -59,12 +59,12 @@ describe('compile', function() {
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'src'), {recursive: true});
fs.writeFileSync(
path.resolve(home, 'src/simple-test.eo'),
path.resolve(home, 'src/simple-test-compile.eo'),
[
'+package foo.bar',
'+junit',
'',
'[] > simple-test',
'[] > simple-test-compile',
' TRUE > @',
'',
].join('\n')
Expand All @@ -80,8 +80,8 @@ describe('compile', function() {
assertFilesExist(
stdout, home,
[
'target/generated-sources/EOfoo/EObar/EOsimple_testTest.java',
'target/classes/EOfoo/EObar/EOsimple_testTest.class',
'target/generated-sources/EOfoo/EObar/EOsimple_test_compileTest.java',
'target/classes/EOfoo/EObar/EOsimple_test_compileTest.class',
]
);
done();
Expand All @@ -91,7 +91,7 @@ describe('compile', function() {
home = path.resolve('temp/test-compile/simple');
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'src'), {recursive: true});
fs.writeFileSync(path.resolve(home, 'src/simple.eo'), simple());
fs.writeFileSync(path.resolve(home, 'src/compile2.eo'), simple('compile2'));
const stdout = runSync([
'compile',
'--clean',
Expand All @@ -107,14 +107,15 @@ describe('compile', function() {

/**
* Creates simple correct eo program.
* @param {string} name - Name of object
* @return {string} simple eo program
*/
function simple() {
function simple(name) {
return [
'+package foo.bar',
'+alias org.eolang.io.stdout',
'',
'[args] > app',
`[args] > ${name}`,
' stdout "Hello, world!" > @',
].join('\n');
}
8 changes: 4 additions & 4 deletions test/commands/test_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ describe('link', function() {
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'src/foo/bar'), {recursive: true});
fs.writeFileSync(
path.resolve(home, 'src/foo/bar/simple.eo'),
path.resolve(home, 'src/foo/bar/link.eo'),
[
'+package foo.bar',
'+alias org.eolang.io.stdout',
'',
'[args] > app',
'[args] > link',
' stdout "Hello, world!" > @',
].join('\n')
);
Expand All @@ -53,9 +53,9 @@ describe('link', function() {
assertFilesExist(
stdout, home,
[
'target/generated-sources/EOfoo/EObar/EOapp.java',
'target/generated-sources/EOfoo/EObar/EOlink.java',
'target/generated-sources/EOorg/EOeolang/EObytes.java',
'target/classes/EOfoo/EObar/EOapp.class',
'target/classes/EOfoo/EObar/EOlink.class',
'target/classes/org/eolang/Phi.class',
'target/classes/EOorg/EOeolang/EOint.class',
'target/eoc.jar',
Expand Down
8 changes: 5 additions & 3 deletions test/commands/test_transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ const {runSync, assertFilesExist} = require('../helpers');

describe('transpile', function() {
it('transpiles a simple .EO program', function(done) {
home = path.resolve('temp/test-transpile/simple');
home = path.resolve('temp/test-transpile/transpile');
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'src'), {recursive: true});
fs.writeFileSync(path.resolve(home, 'src/simple.eo'), '[] > simple\n');
fs.writeFileSync(path.resolve(home, 'src/transpile.eo'), '[] > transpile\n');
const stdout = runSync([
'transpile',
'--verbose',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
assertFilesExist(
stdout, home,
['target/generated-sources/EOsimple.java']
['target/generated-sources/EOtranspile.java']
);
done();
});
Expand Down
1 change: 0 additions & 1 deletion test/commands/test_verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('verify', function() {
const stdout = runSync([
'verify',
'--verbose',
'--debug',
'--track-optimization-steps',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
Expand Down

0 comments on commit a3607b3

Please sign in to comment.