mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-03 19:44:22 +00:00
Tests: Add ControlsKitchenSink and local output to snapshot task
`npx jake snapshot` now builds ControlsKitchenSink as well. When passed a directory path, the task writes the built applications there uncompressed and replaces any existing copies so they can be run locally; without a directory argument, it writes the zip archive as before. Update the README to drop the hardcoded application count.
This commit is contained in:
1 parent
5c9aed0e27
commit
1c7b9af209
1 file changed
+108
-39
+108
-39
@@ -336,31 +336,36 @@ task ("batch-compile-release", function()
|
||||
* The applications that the snapshot archive holds, by their path in this
|
||||
* directory.
|
||||
*/
|
||||
var SnapshotApplications = ["People", "CSVImportTest", "TextEditor"];
|
||||
var SnapshotApplications = ["People", "CSVImportTest", "TextEditor", "ControlsKitchenSink"];
|
||||
|
||||
/*
|
||||
* Makes a zip archive of ready-to-run release builds of the integration test
|
||||
* applications, for testers who do not build Cappuccino:
|
||||
* Makes ready-to-run release builds of the integration test applications:
|
||||
*
|
||||
* npx jake snapshot
|
||||
* npx jake snapshot ~/Sites/Cappuccino
|
||||
*
|
||||
* 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.
|
||||
* Without a destination, the task writes a zip archive for testers who do not
|
||||
* build Cappuccino. The archive goes 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, and it holds a README. zip must be on
|
||||
* the PATH.
|
||||
*
|
||||
* With a destination, the task writes the applications into that directory,
|
||||
* uncompressed, for running them locally. Each application replaces the copy of
|
||||
* the same name there; other entries are left in place. A relative destination
|
||||
* is taken from the directory the command runs in, and a missing one is created.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
task ("snapshot", function()
|
||||
{
|
||||
var manualDir = __dirname,
|
||||
rootDir = path.resolve(manualDir, "../.."),
|
||||
snapshotsDir = path.join(rootDir, "Integration-Test-Snapshots"),
|
||||
destination = snapshotDestination(),
|
||||
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);
|
||||
@@ -373,32 +378,28 @@ task ("snapshot", function()
|
||||
"build the frameworks in both configurations first"
|
||||
);
|
||||
|
||||
if (destination)
|
||||
{
|
||||
fs.mkdirSync(destination, { recursive: true });
|
||||
copySnapshotApplications(appDirs, destination);
|
||||
|
||||
console.log("----------------------------");
|
||||
console.log("Applications written to: " + destination);
|
||||
console.log("----------------------------");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var snapshotsDir = path.join(rootDir, "Integration-Test-Snapshots"),
|
||||
name = "Cappuccino-Integration-Tests-" + snapshotDate() + "-" + revision,
|
||||
stagingDir = path.join(snapshotsDir, name),
|
||||
archivePath = stagingDir + ".zip";
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
copySnapshotApplications(appDirs, stagingDir);
|
||||
fs.writeFileSync(path.join(stagingDir, "README.md"), snapshotReadme(revision));
|
||||
|
||||
cp.execFileSync("zip", ["-r", "-q", "-X", path.basename(archivePath), name], { stdio: "inherit", cwd: snapshotsDir });
|
||||
@@ -409,6 +410,74 @@ task ("snapshot", function()
|
||||
console.log("----------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* Returns the absolute path of the destination named after snapshot on the
|
||||
* command line, or null when none is named. Jake runs each word on the command
|
||||
* line as a task, so the destination is also declared as an empty task, which
|
||||
* Jake then runs without effect. A destination that is already a task is
|
||||
* refused, because Jake would run that task, and so is one that starts with ^ or
|
||||
* jake:, which Jake reads as a task scope. Words of the form NAME=value are
|
||||
* Jake's environment settings.
|
||||
*/
|
||||
function snapshotDestination()
|
||||
{
|
||||
var taskIndex = process.argv.indexOf("snapshot"),
|
||||
words = taskIndex < 0 ? [] : process.argv.slice(taskIndex + 1).filter(function(aWord)
|
||||
{
|
||||
return !/^\w+=/.test(aWord);
|
||||
});
|
||||
|
||||
if (words.length === 0)
|
||||
return null;
|
||||
|
||||
if (words.length > 1)
|
||||
throw new Error("Give at most one destination directory: " + words.join(" "));
|
||||
|
||||
var word = words[0];
|
||||
|
||||
if (/^(\^|jake:)/.test(word))
|
||||
throw new Error("A destination cannot start with ^ or jake:, which Jake reads as a task scope");
|
||||
|
||||
if (JAKE.application().lookup(word))
|
||||
throw new Error(word + " is a task in this Jakefile, not a destination");
|
||||
|
||||
JAKE.task(word);
|
||||
|
||||
return path.resolve(ENV["PWD"] || process.cwd(), word);
|
||||
}
|
||||
|
||||
/*
|
||||
* Builds each application in appDirs for release and copies its release product
|
||||
* into aDirectory, replacing a copy of the same name, without Frameworks/Debug and
|
||||
* index-debug.html.
|
||||
*/
|
||||
function copySnapshotApplications(appDirs, aDirectory)
|
||||
{
|
||||
appDirs.forEach(function(appDir)
|
||||
{
|
||||
var appName = path.basename(appDir),
|
||||
productDir = path.join(appDir, "Build", "Release", appName),
|
||||
targetDir = path.join(aDirectory, 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.rmSync(targetDir, { recursive: true, force: true });
|
||||
fs.cpSync(productDir, targetDir, {
|
||||
recursive: true,
|
||||
filter: function(aPath)
|
||||
{
|
||||
return excluded.indexOf(aPath) < 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -453,9 +522,9 @@ function snapshotReadme(revision)
|
||||
"- **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.",
|
||||
"This archive contains release builds of 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",
|
||||
"",
|
||||
|
||||
Reference in new issue
Block a user