Skip to content

Commit

Permalink
self-test: prepare apps after createApp
Browse files Browse the repository at this point in the history
This means that the first command won't need to do a big build (and
print lots of package changed notifications). Similar to what 'meteor
create' does.

Also add --prepare-app command.
  • Loading branch information
glasser committed Dec 1, 2014
1 parent dc97864 commit c49a441
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 13 deletions.
19 changes: 19 additions & 0 deletions tools/commands-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ main.registerCommand({
});


// Internal use only. A simpler version of --get-ready which doesn't try to also
// build/download local and release packages that aren't currently used. Just
// builds and downloads packages used by the current app.
main.registerCommand({
name: '--prepare-app',
pretty: true,
requiresApp: true,
catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false })
}, function (options) {
var projectContext = new projectContextModule.ProjectContext({
projectDir: options.appDir
});
main.captureAndExit("=> Errors while initializing project:", function () {
projectContext.prepareProjectForBuild();
});
projectContext.packageMapDelta.displayOnConsole();
});


///////////////////////////////////////////////////////////////////////////////
// publish a package
///////////////////////////////////////////////////////////////////////////////
Expand Down
23 changes: 21 additions & 2 deletions tools/selftest.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,16 +561,35 @@ _.extend(Sandbox.prototype, {
// For example:
// s.createApp('myapp', 'empty');
// s.cd('myapp');
createApp: function (to, template) {
createApp: function (to, template, options) {
var self = this;
options = options || {};
files.cp_r(path.join(__dirname, 'tests', 'apps', template),
path.join(self.cwd, to),
{ ignore: [/^local$/] });
// If the test isn't explicitly managing a mock warehouse, ensure that apps
// run with our release by default.
if (!self.warehouse && release.current.isProperRelease()) {
if (options.release) {
self.write(path.join(to, '.meteor/release'), options.release);
} else if (!self.warehouse && release.current.isProperRelease()) {
self.write(path.join(to, '.meteor/release'), release.current.name);
}

if (options.dontPrepareApp)
return;

// Prepare the app (ie, build or download packages). We give this a nice
// long timeout, which allows the next command to not need a bloated
// timeout. (meteor create does this anyway.)
self.cd(to, function () {
var run = self.run("--prepare-app");
// XXX Can we cache the output of running this once somewhere, so that
// multiple calls to createApp with the same template get the same cache?
// This is a little tricky because isopack-buildinfo.json uses absolute
// paths.
run.waitSecs(20);
run.expectExit(0);
});
},

// Same as createApp, but with a package.
Expand Down
5 changes: 2 additions & 3 deletions tools/tests/autoupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ selftest.define("autoupdate", ['checkout'], function () {
// manages to run. So stop mongo from starting so that it goes faster.
s.set("MONGO_URL", "whatever");

s.createApp('myapp', 'packageless');
s.createApp('myapp', 'packageless', { release: 'METEOR@v2' });
s.cd('myapp', function () {
setBanner(s, "v2", "=> New hotness v2 being downloaded.\n");
s.write('.meteor/release', 'METEOR@v2');

// console.log("WE ARE READY NOW", s.warehouse, s.cwd)
// require('../utils.js').sleepMs(1000*10000)

// Run it and see the banner for the current version.
run = s.run("--port", "21000");
run.waitSecs(5);
run.waitSecs(30);
run.match("New hotness v2 being downloaded");
run.match("running at");
run.stop();
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ selftest.define("npm", ["net"], function () {
var s = new Sandbox({ fakeMongo: true });
var run;

s.createApp("npmtestapp", "npmtest");
s.createApp("npmtestapp", "npmtest", { dontPrepareApp: true });
s.cd("npmtestapp");

// Ensure that we don't lose the executable bits of npm modules.
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ selftest.define("unknown release", [], function () {
s.set("METEOR_OFFLINE_CATALOG", "t");
var run;

s.createApp('myapp', 'packageless');
s.createApp('myapp', 'packageless', { dontPrepareApp: true });
s.cd('myapp');
run = s.run("--release", "bad");
run.matchErr("Meteor bad: unknown release");
Expand Down
7 changes: 3 additions & 4 deletions tools/tests/report-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ selftest.define("report-stats", ["slow", "net"], function () {

var run;

s.createApp("foo", "package-stats-tests");
s.createApp("foo", "package-stats-tests", {
release: useFakeRelease ? 'METEOR@v1' : undefined
});
s.cd("foo");
if (useFakeRelease) {
s.write('.meteor/release', 'METEOR@v1');
}

var projectContext = new projectContextModule.ProjectContext({
projectDir: s.cwd
Expand Down
3 changes: 1 addition & 2 deletions tools/tests/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,10 @@ selftest.define("update during run", ["checkout"], function () {
});
var run;

s.createApp("myapp", "packageless");
s.createApp("myapp", "packageless", { release: 'METEOR@v1' });
s.cd("myapp");

// If the app version changes, we exit with an error message.
s.write('.meteor/release', 'METEOR@v1');
run = s.run();
run.tellMongo(MONGO_LISTENING);
run.waitSecs(10);
Expand Down

0 comments on commit c49a441

Please sign in to comment.