Skip to content

Commit aff82c2

Browse files
committed
cleanup, types
1 parent a83514d commit aff82c2

File tree

7 files changed

+24
-36
lines changed

7 files changed

+24
-36
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
test
22
node_modules
33
.cache
4+
report.json
45
tsconfig.json
56
tslint.json
67
src

lib/create-runner.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22
var path = require('path');
3-
require('./loaders');
43
var spawn = require('child_process').spawn;
54
var node = null;
65
if (process.platform === 'darwin' && process.resourcesPath) {
@@ -20,9 +19,6 @@ function createRunner(config, testFile) {
2019
options.env = Object.create(process.env);
2120
}
2221
options.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE = 1;
23-
options.env.DIR = config.dir;
24-
options.env.TUTORIAL_DIR = config.tutorialDir;
25-
options.env.TASK_POSITION = config.taskPosition;
2622
return spawn(node, [
2723
'py.test',
2824
'--json=report.json',

lib/runner.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ function runner(testFile, config, handleResult) {
1010
return new Promise(function (resolve, reject) {
1111
runner.stdout.on('data', function (data) {
1212
data = data.toString();
13-
console.log(data);
1413
if (!exists_1.default(pathToResults)) {
1514
console.log('error finding test output file: ', data);
1615
return;

src/create-runner.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as path from 'path';
2-
import './loaders';
32
const spawn = require('child_process').spawn;
43

54
// get absolute path to node exec
@@ -21,9 +20,6 @@ export function createRunner(config: CR.Config, testFile: string) {
2120
options.env = Object.create(process.env);
2221
}
2322
options.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE = 1;
24-
options.env.DIR = config.dir;
25-
options.env.TUTORIAL_DIR = config.tutorialDir;
26-
options.env.TASK_POSITION = config.taskPosition;
2723

2824
// spawn child process calling test runner
2925
return spawn(node, [

src/parse-json.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
let final = null;
1+
let final: ParseFinal = null;
22
const testNumber = /::Test([0-9]+)/;
33
const testMessage = /::test_(.+)$/;
44

5-
interface ParseFinal {
6-
complete: boolean;
7-
msg: string;
8-
taskPosition: number;
9-
timedOut?: boolean;
10-
}
11-
125
function formatFailureMessage(message: string): string {
136
return message.split('_').join(' ');
147
}
@@ -20,8 +13,8 @@ export function parseJson(pathToResults: string): ParseFinal {
2013
return;
2114
}
2215

23-
let finalIndex = result.report.summary.num_tests - 1;
24-
let finalTest = result.report.tests.find(function(test) {
16+
let finalIndex: number = result.report.summary.num_tests - 1;
17+
let finalTest: PyTest = result.report.tests.find(function(test: PyTest) {
2518
return test.run_index === finalIndex;
2619
});
2720
let taskPosition: number = parseInt(finalTest.name.match(testNumber)[1], 10);
@@ -31,7 +24,7 @@ export function parseJson(pathToResults: string): ParseFinal {
3124
return;
3225
}
3326

34-
let failed = result.report.summary.failed > 0;
27+
let failed: boolean = result.report.summary.failed > 0;
3528

3629
if (!failed) {
3730
// pass

src/runner.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ export default function runner(testFile: string, config: CR.Config,
1515
runner.stdout.on('data', function(data): void {
1616

1717
data = data.toString();
18-
console.log(data);
19-
20-
/* Result */
21-
// transform string result into object
2218

2319
if (!exists(pathToResults)) {
2420
console.log('error finding test output file: ', data);
2521
return;
2622
}
2723

24+
// transform data;
2825
final = parseJson(pathToResults);
2926
final.change = final.taskPosition - config.taskPosition;
3027
final.pass = final.change > 0;

src/typings/cr/globals.d.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
interface Global {
2-
loadEditor: (pathToContext: string, options?: Object) => void;
3-
loadGlobal: (name: string, pathToContext: string) => void;
1+
interface ParseFinal {
2+
completed: boolean;
3+
msg: string;
4+
taskPosition: number;
5+
timedOut?: boolean;
46
}
57

6-
interface ObjectConstructor {
7-
assign(target: any, ...sources: any[]): any;
8-
}
9-
10-
declare var global: Global;
11-
12-
declare module 'babel-core' {
13-
var babel: any;
14-
export default babel;
8+
interface PyTest {
9+
name: string;
10+
teardown: Object;
11+
setup: Object;
12+
run_index: number;
13+
call: {
14+
duration: number;
15+
outcome: string;
16+
name: string;
17+
longrepr: string;
18+
};
19+
duration: number;
20+
outcome: string;
1521
}

0 commit comments

Comments
 (0)