Commit 981e1d06 authored by nanahira's avatar nanahira

allow yrp subdir

parent 2d0e8878
Pipeline #42895 passed with stages
in 2 minutes and 23 seconds
......@@ -11,18 +11,20 @@ async function main() {
process.exit(1);
}
for (const yrpFilename of yrpFilenames) {
const yrpParts = yrpFilename.split("/").filter((part) => part.length > 0);
const fullPath = path.resolve(
process.cwd(),
"tests",
"yrp",
`${yrpFilename}.yrp`,
path.join(...yrpParts) + ".yrp",
);
const destPath = path.resolve(
process.cwd(),
"tests",
"yrp-info",
`${yrpFilename}.yaml`,
path.join(...yrpParts) + ".yaml",
);
await fs.promises.mkdir(path.dirname(destPath), { recursive: true });
console.log(`Will save YRP info from ${fullPath} to ${destPath}`);
await createTest({ yrp: fullPath }, async (test) => {
const info = toYrpInfo(test);
......
......@@ -7,22 +7,38 @@ import fs from "node:fs";
describe("YRP", () => {
const yrpDirPath = path.resolve(process.cwd(), "tests", "yrp");
const yrpDir = readdirSync(yrpDirPath);
for (const yrpFilename of yrpDir) {
if (!yrpFilename.endsWith(".yrp")) continue;
const testName = `YRP: ${yrpFilename}`;
const listYrpFiles = (dirPath: string, basePath: string): string[] => {
const entries = readdirSync(dirPath, { withFileTypes: true });
const results: string[] = [];
for (const entry of entries) {
const entryPath = path.join(dirPath, entry.name);
if (entry.isDirectory()) {
results.push(...listYrpFiles(entryPath, basePath));
continue;
}
if (entry.isFile() && entry.name.endsWith(".yrp")) {
results.push(path.relative(basePath, entryPath));
}
}
return results;
};
const yrpFiles = listYrpFiles(yrpDirPath, yrpDirPath).sort();
for (const yrpRelativePath of yrpFiles) {
const testName = `YRP: ${yrpRelativePath}`;
it(testName, async () => {
const yrpPath = path.resolve(yrpDirPath, yrpFilename);
const yrpPath = path.resolve(yrpDirPath, yrpRelativePath);
await createTest({ yrp: yrpPath }, async (test) => {
const yrpInfoPath = path.resolve(
__dirname,
process.cwd(),
"tests",
"yrp-info",
yrpFilename.slice(0, -4) + ".yaml",
yrpRelativePath.replace(/\.yrp$/i, ".yaml"),
);
const currentInfo = toYrpInfo(test);
const hasYrpInfo = existsSync(yrpInfoPath);
console.log(
`Testing YRP: ${yrpFilename}\nYRP info yaml: ${hasYrpInfo ? "available" : "none"}\n${currentInfo.snapshotText}`,
`Testing YRP: ${yrpRelativePath}\nYRP info yaml: ${hasYrpInfo ? "available" : "none"}\n${currentInfo.snapshotText}`,
);
if (hasYrpInfo) {
// do further tests
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment