tstest/ts/tstest.classes.testdirectory.ts

58 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-03-12 23:30:32 +00:00
import * as plugins from './tstest.plugins.js';
import * as paths from './tstest.paths.js';
2023-11-09 16:55:26 +00:00
import { SmartFile } from '@push.rocks/smartfile';
2018-08-03 17:18:42 +00:00
// tap related stuff
2022-03-12 23:30:32 +00:00
import { TapCombinator } from './tstest.classes.tap.combinator.js';
import { TapParser } from './tstest.classes.tap.parser.js';
import { TapTestResult } from './tstest.classes.tap.testresult.js';
2018-08-03 17:18:42 +00:00
export class TestDirectory {
/**
* the current working directory
*/
cwd: string;
/**
* the relative location of the test dir
*/
relativePath: string;
/**
* the absolute path of the test dir
*/
absolutePath: string;
/**
* an array of Smartfiles
*/
2023-11-09 16:55:26 +00:00
testfileArray: SmartFile[] = [];
2018-08-03 17:18:42 +00:00
/**
* the constructor for TestDirectory
* tell it the path
* @param pathToTestDirectory
*/
constructor(cwdArg: string, relativePathToTestDirectory: string) {
this.cwd = cwdArg;
this.relativePath = relativePathToTestDirectory;
}
private async _init() {
this.testfileArray = await plugins.smartfile.fs.fileTreeToObject(
plugins.path.join(this.cwd, this.relativePath),
2019-10-02 08:56:02 +00:00
'test*.ts'
2018-08-03 17:18:42 +00:00
);
}
async getTestFilePathArray() {
await this._init();
const testFilePaths: string[] = [];
for (const testFile of this.testfileArray) {
const filePath = plugins.path.join(this.relativePath, testFile.path);
testFilePaths.push(filePath);
}
return testFilePaths;
}
}