mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-24 13:11:06 +00:00
test: harden sparse Testbox scans
This commit is contained in:
@@ -37,6 +37,7 @@ function listGitSourceFiles(dir: string): string[] | null {
|
||||
}
|
||||
return files
|
||||
.map((file) => path.join(REPO_ROOT, file))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.filter(isOwnedSourceFile)
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ function listGitSourceFiles(repoPath: string): string[] | null {
|
||||
}
|
||||
return files
|
||||
.map((filePath) => path.join(REPO_ROOT, filePath))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.filter(isSourceFile)
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ function listGitTrackedTsFiles(rootRelativePath: string, filter: FileFilter): st
|
||||
.filter((line) => line.endsWith(".ts"))
|
||||
.filter((line) => !(filter.excludeTests && line.endsWith(".test.ts")))
|
||||
.filter((line) => !(filter.testOnly && !line.endsWith(".test.ts")))
|
||||
.filter((line) => fs.existsSync(resolve(REPO_ROOT, line)))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ function listTrackedSourceFiles(dir: string): string[] | null {
|
||||
return files
|
||||
.filter((line) => line.length > 0 && line.endsWith(".ts") && !line.includes("/plugin-sdk/"))
|
||||
.map((line) => path.join(repoRoot, ...line.split("/")))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ function listTrackedCodeFiles(relativeDir: string): string[] | null {
|
||||
}
|
||||
const files = trackedFiles
|
||||
.filter((line) => line.length > 0 && /\.(?:[cm]?ts|tsx|mts|cts)$/u.test(line))
|
||||
.filter((line) => fs.existsSync(resolve(REPO_ROOT, line)))
|
||||
.toSorted();
|
||||
trackedCodeFilesByRoot.set(relativeDir, files);
|
||||
return [...files];
|
||||
|
||||
@@ -94,6 +94,7 @@ function listTrackedFiles(root: string): string[] | null {
|
||||
const files = trackedFiles
|
||||
.filter((line) => line.length > 0 && !isSkippedTrackedPath(line))
|
||||
.map((line) => resolve(REPO_ROOT, line))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.toSorted();
|
||||
trackedFilesByRoot.set(relativeRoot, files);
|
||||
return [...files];
|
||||
|
||||
@@ -342,6 +342,7 @@ function listTrackedRepoTsFiles(dir: string): string[] | null {
|
||||
line.endsWith(".ts") && !line.includes("/dist/") && !line.includes("/node_modules/"),
|
||||
)
|
||||
.map((line) => resolve(REPO_ROOT, ...line.split("/")))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ function listGitFiles(dir: string): string[] | null {
|
||||
return files
|
||||
.filter((line) => !isSkippedRepoPath(line))
|
||||
.map((line) => path.join(process.cwd(), ...line.split("/")))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
@@ -73,6 +74,7 @@ function listGitPluginManifestPaths(extensionsDir: string): string[] | null {
|
||||
return files
|
||||
.filter((line) => /^extensions\/[^/]+\/openclaw\.plugin\.json$/u.test(line))
|
||||
.map((line) => path.join(process.cwd(), ...line.split("/")))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ function listGitProductionSourceFiles(root: string): string[] | null {
|
||||
return files
|
||||
.filter(isProductionSourcePath)
|
||||
.map((line) => path.join(repoRoot, ...line.split("/")))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ function listGitFiles(dir: string): string[] | null {
|
||||
return files
|
||||
.filter((line) => !shouldSkipScannedPath(line))
|
||||
.map((line) => resolve(REPO_ROOT, line))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ function listGitSourceFiles(dir: string): string[] | null {
|
||||
}
|
||||
return files
|
||||
.map((file) => resolve(repoRoot, file))
|
||||
.filter((filePath) => fs.existsSync(filePath))
|
||||
.filter(isProductionTypeScriptFile)
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ function listGitProductionToolModuleFiles(): string[] | null {
|
||||
.filter((line) => line.startsWith("src/tools/"))
|
||||
.map((line) => line.slice("src/tools/".length))
|
||||
.filter((name) => name.endsWith(".ts") && !name.endsWith(".test.ts"))
|
||||
.filter((name) => fs.existsSync(new URL(name, toolsDir)))
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user