🐛 Simplified test path finding
This commit is contained in:
221
tests/index.js
221
tests/index.js
@@ -1063,108 +1063,167 @@ class PakeTestRunner {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enhanced file finding with better Windows support
|
// Simplified build output detection - if build succeeds, check for any output files
|
||||||
findBuildOutputFiles(testName, expectedFiles, platform) {
|
findBuildOutputFiles(testName, expectedFiles, platform) {
|
||||||
const foundFiles = [];
|
const foundFiles = [];
|
||||||
|
console.log(` 🔍 Checking for ${platform} build outputs...`);
|
||||||
|
|
||||||
// Check different possible locations based on platform
|
// Simple approach: look for common build artifacts in project root and common locations
|
||||||
const searchDirs = [];
|
const searchLocations = [
|
||||||
|
// Always check project root first (most builds output there)
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
// Platform-specific bundle directories
|
||||||
|
...(platform === "linux"
|
||||||
|
? [
|
||||||
|
path.join(config.PROJECT_ROOT, "src-tauri/target/release"),
|
||||||
|
path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
"src-tauri/target/release/bundle/deb",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(platform === "win32"
|
||||||
|
? [
|
||||||
|
path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
"src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi",
|
||||||
|
),
|
||||||
|
path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
"src-tauri/target/release/bundle/msi",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(platform === "darwin"
|
||||||
|
? [
|
||||||
|
path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
"src-tauri/target/release/bundle/macos",
|
||||||
|
),
|
||||||
|
path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
"src-tauri/target/release/bundle/dmg",
|
||||||
|
),
|
||||||
|
path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
"src-tauri/target/universal-apple-darwin/release/bundle",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
|
||||||
if (platform === "win32") {
|
// Define what we're looking for based on platform
|
||||||
// Windows-specific search directories
|
const buildPatterns = {
|
||||||
searchDirs.push(
|
win32: [".msi", ".exe"],
|
||||||
expectedFiles.app,
|
linux: [".deb", ".appimage"],
|
||||||
expectedFiles.installer,
|
darwin: [".dmg", ".app"],
|
||||||
...(expectedFiles.altDirs || []),
|
};
|
||||||
);
|
|
||||||
} else if (platform === "darwin") {
|
|
||||||
// macOS search
|
|
||||||
searchDirs.push(
|
|
||||||
path.dirname(expectedFiles.app),
|
|
||||||
path.dirname(expectedFiles.installer),
|
|
||||||
expectedFiles.bundleDir,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Linux search
|
|
||||||
searchDirs.push(
|
|
||||||
path.dirname(expectedFiles.app),
|
|
||||||
expectedFiles.installer,
|
|
||||||
expectedFiles.bundleDir,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(
|
const patterns = buildPatterns[platform] || buildPatterns.darwin;
|
||||||
` 🔍 Searching for ${testName} build outputs in ${searchDirs.length} locations...`,
|
|
||||||
);
|
|
||||||
|
|
||||||
searchDirs.forEach((searchDir, index) => {
|
for (const location of searchLocations) {
|
||||||
if (!searchDir || !fs.existsSync(searchDir)) {
|
if (!fs.existsSync(location)) {
|
||||||
console.log(
|
continue;
|
||||||
` ⚠️ Location ${index + 1}: ${searchDir} - Directory not found`,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(` 🔍 Location ${index + 1}: ${searchDir}`);
|
console.log(
|
||||||
|
` 📁 Checking: ${path.relative(config.PROJECT_ROOT, location)}`,
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const files = fs.readdirSync(searchDir);
|
const items = fs.readdirSync(location);
|
||||||
console.log(
|
const buildFiles = items.filter((item) => {
|
||||||
` Found ${files.length} files/dirs: [${files.join(", ")}]`,
|
const itemPath = path.join(location, item);
|
||||||
);
|
const stats = fs.statSync(itemPath);
|
||||||
|
|
||||||
// Look for files matching our test name or common patterns
|
// Skip common non-build directories
|
||||||
const relevantFiles = files.filter((file) => {
|
if (
|
||||||
const lowerFile = file.toLowerCase();
|
stats.isDirectory() &&
|
||||||
const lowerTestName = testName.toLowerCase();
|
[".git", ".github", "node_modules", "src", "bin", "tests"].includes(
|
||||||
|
item,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it's a build artifact we care about
|
||||||
|
const lowerItem = item.toLowerCase();
|
||||||
return (
|
return (
|
||||||
lowerFile.includes(lowerTestName) ||
|
patterns.some((pattern) => lowerItem.endsWith(pattern)) ||
|
||||||
lowerFile.includes("github") ||
|
lowerItem.includes(testName.toLowerCase()) ||
|
||||||
lowerFile.endsWith(".msi") ||
|
(lowerItem.includes("github") && !item.startsWith(".")) || // Avoid .github directory
|
||||||
lowerFile.endsWith(".exe") ||
|
(platform === "linux" && item === "pake")
|
||||||
lowerFile.endsWith(".dmg") ||
|
); // Linux binary
|
||||||
lowerFile.endsWith(".deb") ||
|
|
||||||
lowerFile.endsWith(".appimage") ||
|
|
||||||
lowerFile.endsWith(".app")
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
relevantFiles.forEach((file) => {
|
buildFiles.forEach((file) => {
|
||||||
const fullPath = path.join(searchDir, file);
|
const fullPath = path.join(location, file);
|
||||||
const stats = fs.statSync(fullPath);
|
const stats = fs.statSync(fullPath);
|
||||||
|
|
||||||
if (stats.isFile()) {
|
let fileType = "Build Artifact";
|
||||||
let fileType = "Unknown";
|
if (file.endsWith(".msi")) fileType = "MSI Installer";
|
||||||
if (file.endsWith(".msi")) fileType = "MSI Installer";
|
else if (file.endsWith(".exe")) fileType = "Windows Executable";
|
||||||
else if (file.endsWith(".exe")) fileType = "Executable";
|
else if (file.endsWith(".deb")) fileType = "DEB Package";
|
||||||
else if (file.endsWith(".dmg")) fileType = "DMG Image";
|
else if (file.endsWith(".appimage")) fileType = "AppImage";
|
||||||
else if (file.endsWith(".deb")) fileType = "DEB Package";
|
else if (file.endsWith(".dmg")) fileType = "DMG Image";
|
||||||
else if (file.endsWith(".appimage")) fileType = "AppImage";
|
else if (file.endsWith(".app"))
|
||||||
else if (file.endsWith(".app")) fileType = "macOS App";
|
fileType = stats.isDirectory() ? "macOS App Bundle" : "macOS App";
|
||||||
|
else if (file === "pake") fileType = "Linux Binary";
|
||||||
|
|
||||||
foundFiles.push({
|
foundFiles.push({
|
||||||
path: fullPath,
|
path: fullPath,
|
||||||
type: fileType,
|
type: fileType,
|
||||||
size: stats.size,
|
size: stats.isFile() ? stats.size : 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(` ✅ Found ${fileType}: ${file}`);
|
const size =
|
||||||
} else if (stats.isDirectory() && file.endsWith(".app")) {
|
stats.isFile() && stats.size > 0
|
||||||
foundFiles.push({
|
? ` (${(stats.size / 1024 / 1024).toFixed(1)}MB)`
|
||||||
path: fullPath,
|
: "";
|
||||||
type: "macOS App Bundle",
|
console.log(` ✅ Found ${fileType}: ${file}${size}`);
|
||||||
size: 0,
|
|
||||||
});
|
|
||||||
console.log(` ✅ Found macOS App Bundle: ${file}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
|
||||||
console.log(` ❌ Error reading directory: ${error.message}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(` 📊 Total found files: ${foundFiles.length}`);
|
// For Linux, also check inside architecture directories
|
||||||
|
if (platform === "linux") {
|
||||||
|
const archDirs = items.filter(
|
||||||
|
(item) => item.includes("amd64") || item.includes("x86_64"),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const archDir of archDirs) {
|
||||||
|
const archPath = path.join(location, archDir);
|
||||||
|
if (fs.statSync(archPath).isDirectory()) {
|
||||||
|
console.log(` 🔍 Checking arch directory: ${archDir}`);
|
||||||
|
try {
|
||||||
|
const archFiles = fs.readdirSync(archPath);
|
||||||
|
archFiles
|
||||||
|
.filter((f) => f.endsWith(".deb"))
|
||||||
|
.forEach((debFile) => {
|
||||||
|
const debPath = path.join(archPath, debFile);
|
||||||
|
const debStats = fs.statSync(debPath);
|
||||||
|
foundFiles.push({
|
||||||
|
path: debPath,
|
||||||
|
type: "DEB Package",
|
||||||
|
size: debStats.size,
|
||||||
|
});
|
||||||
|
const size = `(${(debStats.size / 1024 / 1024).toFixed(1)}MB)`;
|
||||||
|
console.log(
|
||||||
|
` ✅ Found DEB Package: ${debFile} ${size}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(
|
||||||
|
` ⚠️ Could not check ${archDir}: ${error.message}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(` ⚠️ Could not read ${location}: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(` 📊 Found ${foundFiles.length} build artifact(s)`);
|
||||||
return foundFiles;
|
return foundFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user