fix(tstest): Improve file range filtering and summary logging by skipping test files outside the specified range and reporting them in the final summary.
This commit is contained in:
@@ -39,26 +39,9 @@ export class TsTest {
|
||||
|
||||
async run() {
|
||||
const testGroups = await this.testDir.getTestFileGroups();
|
||||
let allFiles = [...testGroups.serial, ...Object.values(testGroups.parallelGroups).flat()];
|
||||
const allFiles = [...testGroups.serial, ...Object.values(testGroups.parallelGroups).flat()];
|
||||
|
||||
// Apply file range filtering if specified
|
||||
if (this.startFromFile !== null || this.stopAtFile !== null) {
|
||||
const startIndex = this.startFromFile ? this.startFromFile - 1 : 0; // Convert to 0-based index
|
||||
const endIndex = this.stopAtFile ? this.stopAtFile : allFiles.length;
|
||||
allFiles = allFiles.slice(startIndex, endIndex);
|
||||
|
||||
// Filter the serial and parallel groups based on remaining files
|
||||
testGroups.serial = testGroups.serial.filter(file => allFiles.includes(file));
|
||||
Object.keys(testGroups.parallelGroups).forEach(groupName => {
|
||||
testGroups.parallelGroups[groupName] = testGroups.parallelGroups[groupName].filter(file => allFiles.includes(file));
|
||||
// Remove empty groups
|
||||
if (testGroups.parallelGroups[groupName].length === 0) {
|
||||
delete testGroups.parallelGroups[groupName];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Log test discovery
|
||||
// Log test discovery - always show full count
|
||||
this.logger.testDiscovery(
|
||||
allFiles.length,
|
||||
this.testDir.testPath,
|
||||
@@ -71,7 +54,7 @@ export class TsTest {
|
||||
// Execute serial tests first
|
||||
for (const fileNameArg of testGroups.serial) {
|
||||
fileIndex++;
|
||||
await this.runSingleTest(fileNameArg, fileIndex, allFiles.length, tapCombinator);
|
||||
await this.runSingleTestOrSkip(fileNameArg, fileIndex, allFiles.length, tapCombinator);
|
||||
}
|
||||
|
||||
// Execute parallel groups sequentially
|
||||
@@ -85,7 +68,7 @@ export class TsTest {
|
||||
// Run all tests in this group in parallel
|
||||
const parallelPromises = groupFiles.map(async (fileNameArg) => {
|
||||
fileIndex++;
|
||||
return this.runSingleTest(fileNameArg, fileIndex, allFiles.length, tapCombinator);
|
||||
return this.runSingleTestOrSkip(fileNameArg, fileIndex, allFiles.length, tapCombinator);
|
||||
});
|
||||
|
||||
await Promise.all(parallelPromises);
|
||||
@@ -96,6 +79,24 @@ export class TsTest {
|
||||
tapCombinator.evaluate();
|
||||
}
|
||||
|
||||
private async runSingleTestOrSkip(fileNameArg: string, fileIndex: number, totalFiles: number, tapCombinator: TapCombinator) {
|
||||
// Check if this file should be skipped based on range
|
||||
if (this.startFromFile !== null && fileIndex < this.startFromFile) {
|
||||
this.logger.testFileSkipped(fileNameArg, fileIndex, totalFiles, `before start range (${this.startFromFile})`);
|
||||
tapCombinator.addSkippedFile(fileNameArg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.stopAtFile !== null && fileIndex > this.stopAtFile) {
|
||||
this.logger.testFileSkipped(fileNameArg, fileIndex, totalFiles, `after stop range (${this.stopAtFile})`);
|
||||
tapCombinator.addSkippedFile(fileNameArg);
|
||||
return;
|
||||
}
|
||||
|
||||
// File is in range, run it
|
||||
await this.runSingleTest(fileNameArg, fileIndex, totalFiles, tapCombinator);
|
||||
}
|
||||
|
||||
private async runSingleTest(fileNameArg: string, fileIndex: number, totalFiles: number, tapCombinator: TapCombinator) {
|
||||
switch (true) {
|
||||
case process.env.CI && fileNameArg.includes('.nonci.'):
|
||||
|
Reference in New Issue
Block a user