Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature alexamil 1506840478713 #184

Merged
merged 33 commits into from
Oct 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
pdev:set
  • Loading branch information
ORESoftware committed Oct 7, 2017
commit ed1aaea0c5e79e1730266ea545f9c02394dc6751
2 changes: 1 addition & 1 deletion exp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

//////

console.log('this is the beginning.');;;;;
console.log('this is the beginning.');
const path = require('path');

console.error(`${path.basename(__dirname)} reporter may be unable to properly indent output.`);
Expand Down
6 changes: 4 additions & 2 deletions lib/exec-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ exports.execSuite = function (suman) {
msg: msg_1
}
}, function () {
console.log(msg_1 + '\n\n');
console.error(new Error(' => Suman usage error => invalid arrow/generator function usage.').stack);
console.error(msg_1 + '\n\n');
var err = new Error('Suman usage error => invalid arrow/generator function usage.').stack;
_suman.logError(err);
_suman.writeTestError(err);
process.exit(suman_constants_1.constants.EXIT_CODES.INVALID_ARROW_FUNCTION_USAGE);
});
}
Expand Down
5 changes: 3 additions & 2 deletions lib/exec-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ export const execSuite = function (suman: ISuman): Function {
msg: msg
}
}, function () {
console.log(msg + '\n\n');
console.error(new Error(' => Suman usage error => invalid arrow/generator function usage.').stack);
console.error(msg + '\n\n');
let err = new Error('Suman usage error => invalid arrow/generator function usage.').stack;
_suman.logError(err); _suman.writeTestError(err);
process.exit(constants.EXIT_CODES.INVALID_ARROW_FUNCTION_USAGE);
});

Expand Down
5 changes: 0 additions & 5 deletions lib/handle-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ if (!process.prependOnceListener) {
process.prependOnceListener('exit', function (code) {
var testDebugLogPath = _suman.testDebugLogPath;
debugger;
_suman.logError('beginning of exit handler.');
if (errors.length > 0) {
code = code || constants.EXIT_CODES.UNEXPECTED_NON_FATAL_ERROR;
errors.forEach(function (e) {
Expand All @@ -31,8 +30,6 @@ process.prependOnceListener('exit', function (code) {
code = code || constants.EXIT_CODES.TEST_CASE_FAIL;
}
if (testDebugLogPath) {
_suman.logError('BEGIN of log log log.');
_suman.logError('END of log log log.');
}
_suman.writeTestError('\n\n ### Suman end run ### \n\n\n\n', { suppress: true });
if (code > 0 && testErrors.length < 1) {
Expand Down Expand Up @@ -77,7 +74,5 @@ process.prependOnceListener('exit', function (code) {
_suman.logError('killing daemon process, using absolute last hook.');
_suman.absoluteLastHook(code);
}
_suman.logError('doing the very last thing whoa.');
_suman.logError('setting final exit code now.');
process.exitCode = code;
});
12 changes: 2 additions & 10 deletions lib/handle-exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ if (!process.prependOnceListener) {
process.prependOnceListener('exit', function (code: number) {

const testDebugLogPath = _suman.testDebugLogPath;

debugger;

_suman.logError('beginning of exit handler.');

if (errors.length > 0) {
code = code || constants.EXIT_CODES.UNEXPECTED_NON_FATAL_ERROR;
errors.forEach(function (e: Error) {
Expand All @@ -54,13 +51,11 @@ process.prependOnceListener('exit', function (code: number) {
code = code || constants.EXIT_CODES.TEST_CASE_FAIL;
}

if(testDebugLogPath){
_suman.logError('BEGIN of log log log.');
if (testDebugLogPath) {
// fs.appendFileSync(testDebugLogPath, 'nonsesnse nonsesnse nosneses\n');
// fs.appendFileSync(testDebugLogPath, 'nonsesnse nonsesnse nosneses\n');
// fs.appendFileSync(testDebugLogPath, 'nonsesnse nonsesnse nosneses\n');
// fs.appendFileSync(testDebugLogPath, 'nonsesnse nonsesnse nosneses\n');
_suman.logError('END of log log log.');
}

_suman.writeTestError('\n\n ### Suman end run ### \n\n\n\n', {suppress: true});
Expand Down Expand Up @@ -114,10 +109,7 @@ process.prependOnceListener('exit', function (code: number) {
_suman.absoluteLastHook(code);
}

_suman.logError('doing the very last thing whoa.');
_suman.logError('setting final exit code now.');
// => we probably don't need this...
// _suman.logError('making final call to process.exit()');
// this is important, because we *can* change the exit code by using this call
process.exitCode = code;
// process.exit(code);

Expand Down
8 changes: 4 additions & 4 deletions lib/helpers/handle-suman-counts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var util = require("util");
var EE = require("events");
var fs = require("fs");
var suman_events_1 = require("suman-events");
var su = require("suman-utils");
var _suman = global.__suman = (global.__suman || {});
var handle_runner_request_response_1 = require("../index-helpers/handle-runner-request-response");
var counts = require('./suman-counts');
Expand All @@ -28,7 +29,9 @@ suiteResultEmitter.once('suman-test-file-complete', function () {
fn = handle_suman_once_post_1.oncePostFn;
}
var codes = results.map(function (i) { return i.exitCode; });
_suman.log(' => All "exit" codes from test suites => ', util.inspect(codes));
if (su.vgt(6)) {
_suman.log(' => All "exit" codes from test suites => ', util.inspect(codes));
}
var highestExitCode = Math.max.apply(null, codes);
fn(function (err) {
err && _suman.logError(err.stack || err);
Expand Down Expand Up @@ -59,10 +62,7 @@ suiteResultEmitter.once('suman-test-file-complete', function () {
}
};
};
_suman.log(' => about to waitForStdioToDrain');
_suman.log(' => about to call process.exit1');
waitForStdioToDrain(function () {
_suman.log(' => about to call process.exit2');
process.exit(highestExitCode);
});
});
Expand Down
10 changes: 4 additions & 6 deletions lib/helpers/handle-suman-counts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ suiteResultEmitter.once('suman-test-file-complete', function () {

// i may not be defined if testsuite (rootsuite) was skipped
resultz = results.map(i => i ? i : null).filter(i => i);

resultz.forEach(function (r) {
resultBroadcaster.emit(String(events.STANDARD_TABLE), r.tableData, r.exitCode);
});
Expand All @@ -50,7 +49,10 @@ suiteResultEmitter.once('suman-test-file-complete', function () {
}

const codes = results.map(i => i.exitCode);
_suman.log(' => All "exit" codes from test suites => ', util.inspect(codes));
if (su.vgt(6)) {
_suman.log(' => All "exit" codes from test suites => ', util.inspect(codes));
}

const highestExitCode = Math.max.apply(null, codes);

fn(function (err: IPseudoError) {
Expand Down Expand Up @@ -91,11 +93,7 @@ suiteResultEmitter.once('suman-test-file-complete', function () {
}
};

_suman.log(' => about to waitForStdioToDrain');
_suman.log(' => about to call process.exit1');

waitForStdioToDrain(function () {
_suman.log(' => about to call process.exit2');
process.exit(highestExitCode)
});

Expand Down
5 changes: 3 additions & 2 deletions lib/helpers/log-stdio-of-child.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ exports.run = function (filePath) {
}
callable = false;
if (process.env.MAKE_SUMAN_LOG !== 'no') {
_suman.log('we are logging child stdout/stderr to files.', '\n');
if (su.vgt(6)) {
_suman.log('we are logging child stdout/stderr to files.', '\n');
}
var timestamp = process.env.SUMAN_RUNNER_TIMESTAMP;
var runId = process.env.SUMAN_RUN_ID;
var logsDir = _suman.sumanConfig.logsDir || _suman.sumanHelperDirRoot + '/logs';
Expand Down Expand Up @@ -80,5 +82,4 @@ exports.run = function (filePath) {
}
});
}
console.log('\n');
};
6 changes: 4 additions & 2 deletions lib/helpers/log-stdio-of-child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export const run = function (filePath: string) {

if (process.env.MAKE_SUMAN_LOG !== 'no') {

_suman.log('we are logging child stdout/stderr to files.', '\n');
if (su.vgt(6)) {
_suman.log('we are logging child stdout/stderr to files.', '\n');
}

const timestamp = process.env.SUMAN_RUNNER_TIMESTAMP;
const runId = process.env.SUMAN_RUN_ID;
const logsDir = _suman.sumanConfig.logsDir || _suman.sumanHelperDirRoot + '/logs';
Expand Down Expand Up @@ -127,5 +130,4 @@ export const run = function (filePath: string) {
});
}

console.log('\n');
};
9 changes: 6 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ var testSuiteRegistrationQueue = async.queue(function (task, cb) {
process.nextTick(task);
}, c);
testSuiteRegistrationQueue.drain = function () {
var suites = testRuns.length === 1 ? 'suite' : 'suites';
_suman.log("Pushing " + testRuns.length + " test " + suites + " onto queue with concurrency " + c + ".\n");
if (su.vgt(5)) {
var suites = testRuns.length === 1 ? 'suite' : 'suites';
_suman.log("Pushing " + testRuns.length + " test " + suites + " onto queue with concurrency " + c + ".\n\n");
}
while (testRuns.length > 0) {
testSuiteQueue.push(testRuns.shift());
}
Expand Down Expand Up @@ -222,7 +224,7 @@ exports.init = function ($module, $opts, confOverride) {
clearTimeout(to);
_suman['$pre'] = JSON.parse(su.customStringify(vals));
_suman.userData = JSON.parse(su.customStringify(iocData));
var suman = suman_1.makeSuman($module, _interface, true, sumanConfig);
var suman = suman_1.makeSuman($module, _interface, opts);
suman.iocData = JSON.parse(su.customStringify(iocData));
var run = execSuite(suman);
try {
Expand Down Expand Up @@ -283,6 +285,7 @@ exports.init = function ($module, $opts, confOverride) {
var create = exports.init.$ingletonian.create = start;
_interface === 'TDD' ? exports.init.$ingletonian.suite = create : exports.init.$ingletonian.describe = create;
loaded = true;
exports.init.$ingletonian.Test = exports.init.$ingletonian;
return exports.init.$ingletonian;
};
exports.autoPass = function (t) {
Expand Down
11 changes: 8 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ const testSuiteRegistrationQueue = async.queue(function (task: Function, cb: Fun
}, c);

testSuiteRegistrationQueue.drain = function () {
const suites = testRuns.length === 1 ? 'suite' : 'suites';
_suman.log(`Pushing ${testRuns.length} test ${suites} onto queue with concurrency ${c}.\n`);
if (su.vgt(5)) {
const suites = testRuns.length === 1 ? 'suite' : 'suites';
_suman.log(`Pushing ${testRuns.length} test ${suites} onto queue with concurrency ${c}.\n\n`);
}

while (testRuns.length > 0) { //explicit for your pleasure
testSuiteQueue.push(testRuns.shift());
}
Expand Down Expand Up @@ -337,7 +340,7 @@ export const init: IInit = function ($module, $opts, confOverride): IStartCreate
_suman.userData = JSON.parse(su.customStringify(iocData));

// suman instance is the main object that flows through entire program
let suman = makeSuman($module, _interface, true, sumanConfig);
let suman = makeSuman($module, _interface, opts);
suman.iocData = JSON.parse(su.customStringify(iocData));
const run = execSuite(suman);

Expand Down Expand Up @@ -410,6 +413,8 @@ export const init: IInit = function ($module, $opts, confOverride): IStartCreate
_interface === 'TDD' ? init.$ingletonian.suite = create : init.$ingletonian.describe = create;

loaded = true;

init.$ingletonian.Test = init.$ingletonian;
return init.$ingletonian;

};
Expand Down
16 changes: 11 additions & 5 deletions lib/run-child-not-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ var process = require('suman-browser-polyfills/modules/process');
var global = require('suman-browser-polyfills/modules/global');
var path = require('path');
var util = require("util");
var su = require("suman-utils");
var chalk = require("chalk");
var sumanUtils = require('suman-utils');
var debug = require('suman-debug')('s');
var _suman = global.__suman = (global.__suman || {});
var constants = require('../config/suman-constants').constants;
var SUMAN_SINGLE_PROCESS = process.env.SUMAN_SINGLE_PROCESS === 'yes';
Expand Down Expand Up @@ -51,18 +50,25 @@ exports.run = function (files) {
if (!process.prependListener) {
process.prependListener = process.on.bind(process);
}
process.prependListener('exit', function (code) {
if (!process.prependOnceListener) {
process.prependOnceListener = process.on.bind(process);
}
process.prependOnceListener('exit', function (code) {
if (!_suman.isActualExitHandlerRegistered) {
_suman.logError(chalk.magenta('Warning, you may have failed to point Suman to an actual Suman test file.'));
_suman.logError(chalk.magenta('Or there was an immediate error, which prevented any other exit handlers from being registered.'));
}
});
if (SUMAN_SINGLE_PROCESS) {
_suman.log('we are in SUMAN_SINGLE_PROCESS mode.');
if (su.vgt(5)) {
_suman.log('We are in "SUMAN_SINGLE_PROCESS" mode: all JavaScript-based tests will be run in a single process.');
}
require('./handle-single-proc').run(files);
}
else {
_suman.log("running this single test file => \"" + files[0] + "\"");
if (su.vgt(5)) {
_suman.log("running this single test file => \"" + chalk.bold(files[0]) + "\"");
}
require('./helpers/log-stdio-of-child').run(files[0]);
require(files[0]);
}
Expand Down
20 changes: 14 additions & 6 deletions lib/run-child-not-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ const path = require('path');
import util = require('util');

//npm
import su = require('suman-utils');
import chalk = require('chalk');

const sumanUtils = require('suman-utils');
const debug = require('suman-debug')('s');

//project
const _suman: IGlobalSumanObj = global.__suman = (global.__suman || {});
const {constants} = require('../config/suman-constants');
Expand Down Expand Up @@ -81,19 +79,29 @@ export const run = function (files: Array<string>) {
process.prependListener = process.on.bind(process);
}

process.prependListener('exit', function (code: number) {
if (!process.prependOnceListener) {
process.prependOnceListener = process.on.bind(process);
}

process.prependOnceListener('exit', function (code: number) {
if (!_suman.isActualExitHandlerRegistered) {
_suman.logError(chalk.magenta('Warning, you may have failed to point Suman to an actual Suman test file.');
_suman.logError(chalk.magenta('Or there was an immediate error, which prevented any other exit handlers from being registered.'));
}
});

if (SUMAN_SINGLE_PROCESS) {
_suman.log('we are in SUMAN_SINGLE_PROCESS mode.');
if (su.vgt(5)) {
_suman.log('We are in "SUMAN_SINGLE_PROCESS" mode: all JavaScript-based tests will be run in a single process.');
}

require('./handle-single-proc').run(files);
}
else {
_suman.log(`running this single test file => "${files[0]}"`);
if (su.vgt(5)) {
_suman.log(`running this single test file => "${chalk.bold(files[0])}"`);
}

require('./helpers/log-stdio-of-child').run(files[0]);
require(files[0]);
}
Expand Down
15 changes: 9 additions & 6 deletions lib/runner-helpers/handle-fatal-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ var _suman = global.__suman = (global.__suman || {});
var resultBroadcaster = _suman.resultBroadcaster = (_suman.resultBroadcaster || new EE());
exports.handleFatalMessage = function ($msg, n, socket) {
var msg = String(typeof $msg.error === 'string' ? $msg.error : util.inspect($msg)).replace(/\n/g, '\n').replace('\t', '');
msg = msg.split('\n').map(function (item, index) {
msg = msg.split('\n')
.concat(su.repeatCharXTimes('_', 115))
.map(function (item, index) {
if (index === 0) {
return item;
}
else {
return su.padWithXSpaces(8) + item;
return su.padWithXSpaces(3) + item;
}
}).join('\n');
})
.join('\n');
var padding = su.padWithXSpaces(2);
var message = [
'\n',
chalk.bgWhite.magenta.bold(' => Suman runner => there was a fatal test suite error - an error was encountered in ' +
chalk.bgWhite.magenta.bold(' There was a fatal test suite error - an error was encountered in ' +
'your test code that prevents Suman '),
chalk.bgWhite.magenta.bold(' from continuing with a particular test suite within the following path: '),
' ',
Expand All @@ -34,9 +38,8 @@ exports.handleFatalMessage = function ($msg, n, socket) {
}
return null;
})(),
' ',
chalk.magenta.bold(msg),
'\n\n'
].filter(function (item) { return item; }).join('\n\t');
].filter(function (item) { return item; }).join('\n' + padding);
resultBroadcaster.emit(String(events.FATAL_TEST_ERROR), message);
};
Loading