Skip to content

Commit

Permalink
actualize current state of the process-rerun
Browse files Browse the repository at this point in the history
  • Loading branch information
potapovDim committed Sep 9, 2020
1 parent 4d3ebd7 commit e2c80a4
Show file tree
Hide file tree
Showing 48 changed files with 874 additions and 1,452 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
allure-results
package-lock.json
ex.js
spa-report
.idea
playground.*
playground.*
built
coverage
18 changes: 6 additions & 12 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
a.js
ex.js
tsconfig.json
po
lib
specs
util
config
node_modules
allure-results
protractor.conf.js
package-lock.json
unit_specs
lol.js
coverage
playground.*
tsconfig.json
jest.config.js
readme.md
61 changes: 0 additions & 61 deletions bin/rerun

This file was deleted.

33 changes: 0 additions & 33 deletions config/protractor.conf.ts

This file was deleted.

5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testTimeout: 10000
};
14 changes: 0 additions & 14 deletions lib/commandExecutorBuilder.js

This file was deleted.

15 changes: 15 additions & 0 deletions lib/commandExecutorBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {buildExecRunner} from './execProc'
// import {buildSpawnRunner} from './spawnProc';

function buildCommandExecutor(notRetriable, {spawn = false, ...runOpts}) {
return buildExecRunner(notRetriable, runOpts)
// TODO will be implemented
// if (spawn) {
// return buildSpawnRunner(notRetriable, runOpts)
// } else {
// }
}

export {
buildCommandExecutor
}
11 changes: 11 additions & 0 deletions lib/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ProcessRerunError extends Error {
constructor(type, message) {
super(message);
this.name = `${type}${this.constructor.name}`;
Error.captureStackTrace(this, this.constructor);
}
}

export {
ProcessRerunError
}
37 changes: 37 additions & 0 deletions lib/exec/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {exec} from 'child_process';
import {millisecondsToMinutes} from '../utils'
import {logger} from '../logger';
import {ProcessRerunError} from '../error';

function execute(cmd: string, executionHolder: {stackTrace: string}, execOpts = {}, debugProcess) {
const startTime = +Date.now();
if ((typeof cmd) !== 'string') {
throw new ProcessRerunError('Type', `cmd (first argument should be a string), current type is ${typeof cmd}`);
}
if ((typeof executionHolder) !== 'object') {
throw new ProcessRerunError('Type', `executionHolder (second argument should be an object), current type is ${typeof executionHolder}`);
}
if (executionHolder === null) {
throw new ProcessRerunError('Type', `executionHolder (second argument should be an object), current type is null`);
}

const execProc = exec(cmd, execOpts, (error, stdout, stderr) => {

logger.info('___________________________________________________________________________');
logger.info(`command for process: ${cmd}`);
logger.info(`process duration: ${millisecondsToMinutes(+Date.now() - startTime)}`);
logger.info(`PID: ${execProc.pid}`);
logger.info(`stdout: ${stdout}`);
if (stderr) logger.error(`stderr: ${stderr}`);
if (error) logger.error(`error: ${error}`);
logger.info('___________________________________________________________________________');

executionHolder.stackTrace += `${stdout}${stderr}`;
});

return execProc;
}

export {
execute
}
130 changes: 0 additions & 130 deletions lib/execProc.js

This file was deleted.

Loading

0 comments on commit e2c80a4

Please sign in to comment.