mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-03 19:44:22 +00:00
Tests: Add a snapshot task for the integration test applications
npx jake snapshot in Tests/Manual builds People, CSVImportTest and TextEditor for release and writes a zip archive of the release products to Integration-Test-Snapshots at the repository root. Git ignores that directory. A README.md in the archive gives the revision and how to run the applications.
This commit is contained in:
1 parent
6e290fb1ba
commit
0b08496edb
2 files changed
+162
No files matched your search
@@ -28,3 +28,4 @@ node_modules
|
||||
/dist/cappuccino/bin
|
||||
Tests/Manual/.Frameworks
|
||||
/Tests/Manual/index.html
|
||||
/Integration-Test-Snapshots
|
||||
@@ -325,3 +325,164 @@ task ("batch-compile-release", function()
|
||||
ENV["CONFIGURATION"] = "Release";
|
||||
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir npx jake release \\;", { stdio: "inherit", env: ENV, cwd: manualDir });
|
||||
});
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
* Integration Test Snapshots
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* The applications that the snapshot archive holds, by their path in this
|
||||
* directory.
|
||||
*/
|
||||
var SnapshotApplications = ["People", "CSVImportTest", "TextEditor"];
|
||||
|
||||
/*
|
||||
* Makes a zip archive of ready-to-run release builds of the integration test
|
||||
* applications, for testers who do not build Cappuccino:
|
||||
*
|
||||
* npx jake snapshot
|
||||
*
|
||||
* Build the frameworks in both configurations first; configure needs both.
|
||||
* The task configures each application, builds it for release, and copies the
|
||||
* release product without Frameworks/Debug and index-debug.html. The archive is
|
||||
* written to Integration-Test-Snapshots at the repository root, which git
|
||||
* ignores, so the path is the same on every host. Its name holds the date and
|
||||
* the revision of the build, with "-modified" when tracked files differ from
|
||||
* that revision. zip must be on the PATH.
|
||||
*/
|
||||
task ("snapshot", function()
|
||||
{
|
||||
var manualDir = __dirname,
|
||||
rootDir = path.resolve(manualDir, "../.."),
|
||||
snapshotsDir = path.join(rootDir, "Integration-Test-Snapshots"),
|
||||
revision = snapshotRevision(rootDir),
|
||||
name = "Cappuccino-Integration-Tests-" + snapshotDate() + "-" + revision,
|
||||
stagingDir = path.join(snapshotsDir, name),
|
||||
archivePath = stagingDir + ".zip",
|
||||
appDirs = SnapshotApplications.map(function(anApplication)
|
||||
{
|
||||
return path.join(manualDir, anApplication);
|
||||
});
|
||||
|
||||
provisionFrameworks(
|
||||
appDirs,
|
||||
path.join(rootDir, "Build", "Release"),
|
||||
path.join(rootDir, "Build", "Debug"),
|
||||
"build the frameworks in both configurations first"
|
||||
);
|
||||
|
||||
fs.rmSync(stagingDir, { recursive: true, force: true });
|
||||
fs.rmSync(archivePath, { force: true });
|
||||
fs.mkdirSync(stagingDir, { recursive: true });
|
||||
|
||||
appDirs.forEach(function(appDir)
|
||||
{
|
||||
var appName = path.basename(appDir),
|
||||
productDir = path.join(appDir, "Build", "Release", appName),
|
||||
excluded = [path.join(productDir, "Frameworks", "Debug"), path.join(productDir, "index-debug.html")];
|
||||
|
||||
console.log("Building " + appName + " for release");
|
||||
|
||||
cp.execSync("npx jake release", { stdio: "inherit", cwd: appDir, env: Object.assign({}, ENV, { CONFIGURATION: "Release" }) });
|
||||
|
||||
if (!fs.existsSync(path.join(productDir, "index.html")))
|
||||
throw new Error(productDir + " has no index.html; the release build of " + appName + " failed");
|
||||
|
||||
fs.cpSync(productDir, path.join(stagingDir, appName), {
|
||||
recursive: true,
|
||||
filter: function(aPath)
|
||||
{
|
||||
return excluded.indexOf(aPath) < 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
fs.writeFileSync(path.join(stagingDir, "README.md"), snapshotReadme(revision));
|
||||
|
||||
cp.execFileSync("zip", ["-r", "-q", "-X", path.basename(archivePath), name], { stdio: "inherit", cwd: snapshotsDir });
|
||||
fs.rmSync(stagingDir, { recursive: true });
|
||||
|
||||
console.log("----------------------------");
|
||||
console.log("Snapshot archive: " + archivePath);
|
||||
console.log("----------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* Returns the short revision of HEAD, with "-modified" when a tracked file
|
||||
* differs from it. package-lock.json is not counted, because npm rewrites it on
|
||||
* every install.
|
||||
*/
|
||||
function snapshotRevision(rootDir)
|
||||
{
|
||||
var revision = cp.execFileSync("git", ["rev-parse", "--short", "HEAD"], { cwd: rootDir, encoding: "utf8" }).trim(),
|
||||
changes = cp.execFileSync("git", ["status", "--porcelain", "--untracked-files=no"], { cwd: rootDir, encoding: "utf8" })
|
||||
.split("\n")
|
||||
.filter(function(aLine)
|
||||
{
|
||||
return aLine && !/ package-lock\.json$/.test(aLine);
|
||||
});
|
||||
|
||||
return changes.length ? revision + "-modified" : revision;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns today's local date as YYYY-MM-DD.
|
||||
*/
|
||||
function snapshotDate()
|
||||
{
|
||||
var now = new Date();
|
||||
|
||||
return [now.getFullYear(), now.getMonth() + 1, now.getDate()].map(function(aNumber)
|
||||
{
|
||||
return String(aNumber).padStart(2, "0");
|
||||
}).join("-");
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the Markdown text of the README that the archive holds.
|
||||
*/
|
||||
function snapshotReadme(revision)
|
||||
{
|
||||
var applications = SnapshotApplications.slice(0, -1).join(", ") + ", and " + SnapshotApplications[SnapshotApplications.length - 1];
|
||||
|
||||
return [
|
||||
"# Cappuccino integration test applications",
|
||||
"",
|
||||
"- **Revision:** " + revision,
|
||||
"- **Date:** " + snapshotDate(),
|
||||
"",
|
||||
"This archive contains release builds of three Cappuccino applications that",
|
||||
"exercise broad portions of the frameworks: " + applications + ". Each",
|
||||
"subdirectory is a complete application; open its `index.html` to run it.",
|
||||
"",
|
||||
"## Opening the applications",
|
||||
"",
|
||||
"- Recommended: serve the extracted directory over HTTP using:",
|
||||
"",
|
||||
" ```",
|
||||
" capp-build smoke serve",
|
||||
" ```",
|
||||
"",
|
||||
"- Any other local HTTP server can also serve the directory.",
|
||||
"- Safari can open `index.html` directly via `file://`. Other browsers restrict",
|
||||
" local file access for subresources and require a local web server.",
|
||||
"",
|
||||
"## What to test",
|
||||
"",
|
||||
"Use the applications as desktop applications. Testing in Firefox,",
|
||||
"Chromium-based browsers, and on Windows is particularly helpful.",
|
||||
"",
|
||||
"## Reporting issues",
|
||||
"",
|
||||
"Include:",
|
||||
"",
|
||||
"- Revision and date listed above",
|
||||
"- Browser name and version",
|
||||
"- Operating system",
|
||||
"- Steps to reproduce the issue",
|
||||
"- Expected behavior and actual behavior",
|
||||
""
|
||||
].join("\n");
|
||||
}
|
||||
Reference in new issue
Block a user