Small tweaks

This commit is contained in:
Pieter Vander Vennet 2022-03-25 16:36:18 +01:00
parent 67be8c8670
commit fda5017a66
4 changed files with 3571 additions and 27 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
*doctest*
node_modules/
dist/

3536
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
{
"$schema": "http://json.schemastore.org/package",
"name": "doctest-ts-improved",
"version": "0.8.0",
"version": "0.8.4",
"description": "doctest support for typescript with Mocha",
"main": "src/main.ts",
"bin": {
@ -11,7 +11,8 @@
"build": "tsc && chmod 755 dist/main.js",
"doctest:watch": "ts-node src/main.ts --tape --watch {src,test}/*.ts | while read file; do echo tape $file; ts-node $file | tap-diff; done",
"test": "ts-node src/main.ts examples/ && ts-node src/main.ts src/ && mocha --require ts-node/register examples/*.ts src/*.ts",
"prettier": "rm -v -f {src,test}/*doctest.ts && prettier --list-different --write src/*ts* test/*ts*"
"prettier": "rm -v -f {src,test}/*doctest.ts && prettier --list-different --write src/*ts* test/*ts*",
"publish": "npm run build && npm publish"
},
"repository": {
"type": "git",

View file

@ -14,7 +14,7 @@ function readDirRecSync(path: string, maxDepth = 999): string[] {
if (stats.isDirectory()) {
// Subdirectory
// @ts-ignore
result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1))
result.push(...readDirRecSync(fullEntry, maxDepth - 1))
} else {
result.push(fullEntry)
}
@ -22,31 +22,36 @@ function readDirRecSync(path: string, maxDepth = 999): string[] {
return result;
}
function main(){
const args = process.argv
console.log(args.join(","))
const directory = args[2].replace(/\/$/, "")
if(directory === "--require"){
console.error("Probably running the testsuite, detects '--require' as second argument. Quitting now")
return;
}
if(directory === undefined){
console.log("Usage: doctest-ts-improved <directory under test>. This will automatically scan recursively for '.ts'-files, excluding 'node_modules' '*.doctest.ts'-files")
}
function main() {
const files = readDirRecSync(directory).filter(p => !p.startsWith("./node_modules") && !p.endsWith(".doctest.ts"))
const noTests : string[] = []
for (const file of files) {
const generated = new TestCreator(file).createTest()
if(generated === 0){
noTests.push(file)
}else{
console.log("Generated tests for "+file+" ("+generated+" tests found)")
const args = process.argv
console.log(args.join(","))
const directory = args[2].replace(/\/$/, "")
if (directory === "--require") {
console.error("Probably running the testsuite, detects '--require' as second argument. Quitting now")
return;
}
if (directory === undefined) {
console.log("Usage: doctest-ts-improved <directory under test>. This will automatically scan recursively for '.ts'-files, excluding 'node_modules' '*.doctest.ts'-files")
}
const files = readDirRecSync(directory)
.filter(p => p.endsWith(".ts"))
.filter(p => p.indexOf("/node_modules/") < 0 && !p.endsWith(".doctest.ts"))
const noTests: string[] = []
for (let i = 0; i < files.length; i++){
const file = files[i];
process.stdout.write(`\r (${i}/${files.length}) inspecting ${file} \r`)
const generated = new TestCreator(file).createTest()
if (generated === 0) {
noTests.push(file)
} else {
console.log("Generated tests for " + file + " (" + generated + " tests found)")
}
}
if (noTests.length > 0) {
console.log("No tests found in: " + noTests.join(", "))
}
}
if(noTests.length > 0){
console.log("No tests found in: "+noTests.join(", "))
}
}
main()