Skip to content

Commit

Permalink
#232: versions
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Feb 14, 2024
1 parent 5793689 commit 73e9623
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 65 deletions.
6 changes: 3 additions & 3 deletions test/commands/test_assemble.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('assemble', function() {
it('assembles a simple .EO program', function(done) {
Expand All @@ -37,8 +37,8 @@ describe('assemble', function() {
'assemble',
'--verbose',
'--track-optimization-steps',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
14 changes: 7 additions & 7 deletions test/commands/test_compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const rel = require('relative');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('compile', function() {
it('compiles a simple .EO program into Java bytecode .class files', function(done) {
Expand All @@ -36,8 +36,8 @@ describe('compile', function() {
fs.writeFileSync(path.resolve(home, 'src/compile.eo'), simple('compile'));
const stdout = runSync([
'compile',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down Expand Up @@ -73,8 +73,8 @@ describe('compile', function() {
const stdout = runSync([
'compile',
'--verbose',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand All @@ -96,8 +96,8 @@ describe('compile', function() {
const stdout = runSync([
'compile',
'--clean',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
67 changes: 37 additions & 30 deletions test/commands/test_dataize.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,43 @@ const rel = require('relative');
const fs = require('fs');
const assert = require('assert');
const path = require('path');
const {runSync} = require('../helpers');
const {runSync, parserVersion, homeHash} = require('../helpers');

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/foo/bar'), {recursive: true});
fs.writeFileSync(
path.resolve(home, 'src/foo/bar/simple.eo'),
[
'+package foo.bar',
'+alias org.eolang.io.stdout',
'',
'[args] > simple',
' stdout "Hello, world!\\n" > @',
].join('\n')
);
const stdout = runSync([
'dataize', 'foo.bar.simple',
'--verbose',
'--stack=64M',
'--clean',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
assert(stdout.includes('Hello, world!'), stdout);
assert(stdout.includes(`The directory ${rel(path.resolve(home, 'target'))} deleted`), stdout);
assert(!fs.existsSync(path.resolve('../../mvnw/target')));
done();
const versions = new Map([
[parserVersion, homeHash],
['0.34.1', '1d605bd872f27494551e9dd2341b9413d0d96d89'],
]);
versions.forEach(function (hash, version) {
describe('dataize', function() {
it('dataizes with ' + version, function(done) {
home = path.resolve('temp/test-dataize/' + version + '/simple');
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'),
[
'+package foo.bar',
'+alias org.eolang.io.stdout',
'',
'[args] > simple',
' stdout "Hello, world!\\n" > @',
].join('\n')
);
const stdout = runSync([
'dataize', 'foo.bar.simple',
'--verbose',
'--stack=64M',
'--clean',
'--parser=' + version,
'--hash=' + hash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
assert(stdout.includes('Hello, world!'), stdout);
assert(stdout.includes(`The directory ${rel(path.resolve(home, 'target'))} deleted`), stdout);
assert(!fs.existsSync(path.resolve('../../mvnw/target')));
done();
});
});
});

6 changes: 3 additions & 3 deletions test/commands/test_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('link', function() {
it('compiles a simple .EO program into an executable .JAR', function(done) {
Expand All @@ -45,8 +45,8 @@ describe('link', function() {
const stdout = runSync([
'link',
'--verbose',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
6 changes: 3 additions & 3 deletions test/commands/test_parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('parse', function() {
it('parses a simple .EO program', function(done) {
Expand All @@ -36,8 +36,8 @@ describe('parse', function() {
const stdout = runSync([
'parse',
'--verbose',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
6 changes: 3 additions & 3 deletions test/commands/test_phi.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('phi', function() {
it('converts XMIR files to PHI files', function(done) {
Expand All @@ -36,8 +36,8 @@ describe('phi', function() {
'phi',
'--verbose',
'--track-optimization-steps',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
14 changes: 10 additions & 4 deletions test/commands/test_print.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('print', function() {
it('converts XMIR files to EO files', function(done) {
Expand All @@ -33,14 +33,20 @@ describe('print', function() {
fs.mkdirSync(path.resolve(home, 'target/2-optimize'), {recursive: true});
fs.writeFileSync(
path.resolve(home, 'target/2-optimize/app.xmir'),
'<program><objects/></program>'
[
'<program ms="0" name="xx" time="2024-01-01T01:01:01"',
'version="0.0.0" dob="2024-01-01T01:01:01" revision="0">',
'<listing/><errors/><sheets/><license/><metas/>',
'<objects><o abstract="" name="foo"/></objects>',
'</program>'
].join(' ')
);
const stdout = runSync([
'print',
'--verbose',
'--track-optimization-steps',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-t', path.resolve(home, 'target'),
]);
assertFilesExist(
Expand Down
6 changes: 3 additions & 3 deletions test/commands/test_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('test', function() {
it('executes a single unit test', function(done) {
Expand All @@ -45,8 +45,8 @@ describe('test', function() {
const stdout = runSync([
'test',
'--verbose',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
6 changes: 3 additions & 3 deletions test/commands/test_transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('transpile', function() {
it('transpiles a simple .EO program', function(done) {
Expand All @@ -35,8 +35,8 @@ describe('transpile', function() {
const stdout = runSync([
'transpile',
'--verbose',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
6 changes: 3 additions & 3 deletions test/commands/test_unphi.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('unphi', function() {
it('converts PHI files to XMIR files', function(done) {
Expand All @@ -36,8 +36,8 @@ describe('unphi', function() {
'unphi',
'--verbose',
'--track-optimization-steps',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-t', path.resolve(home, 'target'),
]);
assertFilesExist(
Expand Down
6 changes: 3 additions & 3 deletions test/commands/test_verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist} = require('../helpers');
const {runSync, assertFilesExist, parserVersion, homeHash} = require('../helpers');

describe('verify', function() {
it('verifies a simple .EO program', function(done) {
Expand All @@ -37,8 +37,8 @@ describe('verify', function() {
'verify',
'--verbose',
'--track-optimization-steps',
'--parser=0.34.1',
'--hash=1d605bd872f27494551e9dd2341b9413d0d96d89',
'--parser=' + parserVersion,
'--hash=' + homeHash,
'-s', path.resolve(home, 'src'),
'-t', path.resolve(home, 'target'),
]);
Expand Down
6 changes: 6 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
* SOFTWARE.
*/

// When you upgrade them, don't forget to place old values to the
// "test_dataize.js" table of versions, in order to make sure we
// do test dataization with all possible old versions.
module.exports.parserVersion = '0.35.1';
module.exports.homeHash = '130afdd1456a0cbafd52aee8d7bc612e1faac547';

/**
* Helper to run EOC command line tool.
*
Expand Down

0 comments on commit 73e9623

Please sign in to comment.