-
-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory * chore: adjust test directory
- Loading branch information
1 parent
af80a3f
commit 7066027
Showing
676 changed files
with
418 additions
and
1,090 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,75 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { escapeSep } from "."; | ||
|
||
export const isDirectory = (p: string) => fs.lstatSync(p).isDirectory(); | ||
export const isFile = (p: string) => fs.lstatSync(p).isFile(); | ||
export const isValidCaseDirectory = (name: string) => | ||
!name.startsWith("_") && !name.startsWith("."); | ||
!name.startsWith("_") && !name.startsWith(".") && name !== "node_modules"; | ||
|
||
export function describeByWalk( | ||
name: string, | ||
sourceBase: string, | ||
distBase: string, | ||
testFile: string, | ||
createCase: (name: string, src: string, dist: string) => void, | ||
whitelist: { | ||
cat?: RegExp; | ||
case?: RegExp; | ||
options: { | ||
type?: "file" | "directory"; | ||
level?: number; | ||
source?: string; | ||
dist?: string; | ||
absoluteDist?: boolean; | ||
} = {} | ||
) { | ||
const categories = fs | ||
.readdirSync(sourceBase) | ||
.filter(isValidCaseDirectory) | ||
.filter(folder => isDirectory(path.join(sourceBase, folder))) | ||
.filter(i => (whitelist?.cat ? whitelist.cat.test(i) : true)) | ||
.map(cat => { | ||
return { | ||
name: cat, | ||
tests: fs | ||
.readdirSync(path.join(sourceBase, cat)) | ||
.filter(isValidCaseDirectory) | ||
.filter(folder => isDirectory(path.join(sourceBase, cat, folder))) | ||
.filter(i => (whitelist?.case ? whitelist.case.test(i) : true)) | ||
.sort() | ||
}; | ||
}); | ||
describe(name, () => { | ||
for (let { name: catName, tests } of categories) { | ||
if (tests.length === 0) continue; | ||
describe(catName, () => { | ||
for (const testName of tests) { | ||
const src = path.join(sourceBase, catName, testName); | ||
const dist = path.join(distBase, catName, testName); | ||
createCase(testName, src, dist); | ||
const testBasename = path | ||
.basename(testFile) | ||
.replace(/\.(diff|hot)?test\.js/, ""); | ||
const testId = testBasename.charAt(0).toLowerCase() + testBasename.slice(1); | ||
const sourceBase = | ||
options.source || path.join(path.dirname(testFile), `${testId}Cases`); | ||
const distBase = | ||
options.dist || path.join(path.dirname(testFile), "js", testId); | ||
const level = options.level || 2; | ||
const type = options.type || "directory"; | ||
const absoluteDist = options.absoluteDist ?? true; | ||
function describeDirectory(dirname: string, currentLevel: number) { | ||
fs.readdirSync(path.join(sourceBase, dirname)) | ||
.filter(isValidCaseDirectory) | ||
.filter(folder => { | ||
const p = path.join(sourceBase, dirname, folder); | ||
if (type === "file" && currentLevel === 1) { | ||
return isFile(p); | ||
} else if (type === "directory" || currentLevel > 1) { | ||
return isDirectory(p); | ||
} else { | ||
return false; | ||
} | ||
}) | ||
.map(folder => { | ||
const caseName = path.join(dirname, folder); | ||
if (currentLevel > 1) { | ||
describeDirectory(caseName, currentLevel - 1); | ||
} else { | ||
const name = escapeSep( | ||
path.join(testId, caseName).split(".").shift()! | ||
); | ||
describe(name, () => { | ||
let source = path.join(sourceBase, caseName); | ||
let dist = ""; | ||
if (absoluteDist) { | ||
dist = path.join(distBase, caseName); | ||
} else { | ||
const relativeDist = options.dist || "dist"; | ||
if (path.isAbsolute(relativeDist)) { | ||
dist = path.join(relativeDist, caseName); | ||
} else { | ||
dist = path.join(sourceBase, caseName, relativeDist); | ||
} | ||
} | ||
createCase(folder, source, dist); | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
describe(testId, () => { | ||
describeDirectory("", level); | ||
}); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./read-config-file"; | ||
export * from "./parse-modules"; | ||
export * from "./directory"; | ||
export * from "./win"; |
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,9 @@ | ||
import path from "path"; | ||
|
||
export function escapeSep(str: string) { | ||
return str.split(path.win32.sep).join(path.posix.sep); | ||
} | ||
|
||
export function escapeEOL(str: string) { | ||
return str.split("\r\n").join("\n").trim(); | ||
} |
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.
7066027
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
7066027
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
Threshold exceeded: ["arco-pro_development-mode_intercept-plugin + exec"]