Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/eoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ program
.option('-c, --clean', 'Delete .eoc directory before running a command')
.option('--debug', 'Print ALL debug messages, heavily overloading the log')
.option('--verbose', 'Print debug messages and full output of child processes')
.option('--pin <version>', 'Fail if eoc version doesn\'t match exactly', version.what);
.option('--pin <version>', 'Fail if eoc version doesn\'t match exactly', version.what)
.option('--update-snapshots', 'Update snapshots in the local repository if they are outdated');

program.command('audit')
.description('Inspect all packages and report their status')
Expand Down
2 changes: 1 addition & 1 deletion src/mvnw.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports.flags = function (opts) {
opts.verbose ? '--errors' : '',
opts.verbose ? '' : '--quiet',
opts.debug ? '--debug' : '',
opts.updateSnapshots ? '--update-snapshots' : '',
`-Deo.sourcesDir=${sources}`,
`-Deo.targetDir=${target}`,
`-Deo.outputDir=${path.resolve(opts.target, 'classes')}`,
Expand Down Expand Up @@ -82,7 +83,6 @@ module.exports.mvnw = function (args, tgt, batch) {
const params = args.filter((t) => t !== '').concat([
'--batch-mode',
'--color=never',
'--update-snapshots',
'--fail-fast',
'--strict-checksums',
]);
Expand Down
66 changes: 54 additions & 12 deletions test/commands/test_print.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,32 @@
* SPDX-License-Identifier: MIT
*/

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const {runSync, assertFilesExist, parserVersion, homeTag, weAreOnline} = require('../helpers');
const content = [
'<object ms="0" time="2024-01-01T01:01:01"',
'version="0.0.0" dob="2024-01-01T01:01:01" revision="0">',
'<listing/><errors/><sheets/><license/><metas/>',
'<o name="foo"/></object>'
].join(' ');

function setup(dir) {
const home = path.resolve(`temp/test-print/${dir}`);
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'target/input'), {recursive: true});
fs.writeFileSync(
path.resolve(home, 'target/input/foo.xmir'),
content
);
return home;
}

describe('print', () => {
before(weAreOnline);
it('converts XMIR files to EO files', (done) => {
const home = path.resolve('temp/test-print/simple');
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'target/input'), {recursive: true});
fs.writeFileSync(
path.resolve(home, 'target/input/foo.xmir'),
[
'<object ms="0" time="2024-01-01T01:01:01"',
'version="0.0.0" dob="2024-01-01T01:01:01" revision="0">',
'<listing/><errors/><sheets/><license/><metas/>',
'<o name="foo"/></object>'
].join(' ')
);
const home = setup('simple');
const stdout = runSync([
'print',
'--verbose',
Expand All @@ -40,4 +47,39 @@ describe('print', () => {
);
done();
});
it('does not add --update--snapshots option if not requested', (done) => {
const home = setup('without-us');
const stdout = runSync([
'print',
'--verbose',
'--track-transformation-steps',
`--parser=${parserVersion}`,
`--home-tag=${homeTag}`,
'--print-input=input',
'--print-output=output',
'-t', path.resolve(home, 'target'),
]);
assert(
!stdout.includes('--update-snapshots'),
`Expected --update-snapshots option to not be included in the command when not requested:\n ${stdout}`);
done();
});
it('adds --update--snapshots option if requested', (done) => {
const home = setup('with-us');
const stdout = runSync([
'print',
'--verbose',
'--track-transformation-steps',
`--parser=${parserVersion}`,
`--home-tag=${homeTag}`,
'--print-input=input',
'--print-output=output',
'--update-snapshots',
'-t', path.resolve(home, 'target'),
]);
assert(
stdout.includes('--update-snapshots'),
`Expected --update-snapshots option to be included in the command when requested:\n ${stdout}`);
done();
});
});