-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup: node 10, rm unused deps, refactor reporters
- Loading branch information
Showing
15 changed files
with
1,367 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
|
||
import { RunnerResult, PerturbConfig } from "../types"; | ||
|
||
export interface Stats { | ||
total: number; | ||
killed: number; | ||
rate: number; | ||
} | ||
|
||
export function stats(results: RunnerResult[]): Stats { | ||
const killed = results.filter(r => r.error).length; | ||
const total = results.length; | ||
return { | ||
total, | ||
killed, | ||
rate: Number((killed / total).toFixed(4)) * 100, | ||
}; | ||
} | ||
|
||
export function identifier(r: RunnerResult, includeErrorMessage = false) { | ||
const loc = r.loc.start.line + "," + r.loc.start.column; | ||
return [ | ||
r.error ? "#DEAD:" : "#ALIVE:", | ||
r.mutatorName, | ||
r.sourceFile.split(".perturb")[1], | ||
`@${loc}`, | ||
(includeErrorMessage && r.error && r.error.message) || "", | ||
].join(" "); | ||
} | ||
|
||
// configurable? | ||
const RECORD_FILE = path.join(__dirname, "../../run-record.json"); | ||
|
||
function writeResult(last: any, s: Stats, root: string) { | ||
last[root] = s; | ||
try { | ||
fs.writeFileSync(RECORD_FILE, JSON.stringify(last)); | ||
} catch (e) { | ||
// log error? | ||
} | ||
} | ||
|
||
export function delta(rs: RunnerResult[], cfg: PerturbConfig) { | ||
const s = stats(rs); | ||
let record: any = {}; | ||
try { | ||
record = require(RECORD_FILE); | ||
if (record[cfg.projectRoot]) { | ||
console.log("change in total:", s.total - record[cfg.projectRoot].total); | ||
console.log( | ||
"change in killed:", | ||
s.killed - record[cfg.projectRoot].killed, | ||
); | ||
} | ||
} catch (e) { | ||
// file doesn't exist | ||
} finally { | ||
writeResult(record, s, cfg.projectRoot); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.