Throw error if package is prodOnly and debugOnly

With self-test.
This commit is contained in:
David Greenspan
2015-08-06 15:47:08 -07:00
parent a34d040229
commit 67b9da63ad
2 changed files with 31 additions and 5 deletions

View File

@@ -609,8 +609,11 @@ _.extend(PackageSource.prototype, {
} else if (key === "prodOnly") {
self.prodOnly = !!value;
} else {
// Do nothing. We might want to add some keys later, and we should err
// on the side of backwards compatibility.
// Do nothing. We might want to add some keys later, and we should err
// on the side of backwards compatibility.
}
if (self.debugOnly && self.prodOnly) {
buildmessage.error("Package can't have both debugOnly and prodOnly set.");
}
});
},

View File

@@ -263,8 +263,7 @@ selftest.define("change packages during hot code push", [], function () {
});
// Add packages through the command line. Make sure that the correct set of
// changes is reflected in .meteor/packages, .meteor/versions and list. Make
// sure that debugOnly packages don't show up in production mode.
// changes is reflected in .meteor/packages, .meteor/versions and list.
selftest.define("add packages to app", [], function () {
var s = new Sandbox();
var run;
@@ -352,8 +351,18 @@ selftest.define("add packages to app", [], function () {
run.match("no-description\n");
run.expectEnd();
run.expectExit(0);
});
// Add a debugOnly package. It should work during a normal run, but print
selftest.define("add debugOnly and prodOnly packages", [], function () {
var s = new Sandbox();
var run;
// Starting a run
s.createApp("myapp", "package-tests");
s.cd("myapp");
s.set("METEOR_OFFLINE_CATALOG", "t");
// Add a debugOnly package. It should work during a normal run, but print
// nothing in production mode.
run = s.run("add", "debug-only");
run.match("debug-only");
@@ -389,6 +398,20 @@ selftest.define("add packages to app", [], function () {
run.expectExit(234);
});
selftest.define("add package with both debugOnly and prodOnly", [], function () {
var s = new Sandbox();
var run;
// Add an app with a package with prodOnly and debugOnly set (an error)
s.createApp("myapp", "debug-only-test", {dontPrepareApp: true});
s.cd("myapp");
run = s.run("--prepare-app");
run.waitSecs(20);
run.matchErr("can't have both debugOnly and prodOnly");
run.expectExit(1);
});
// Add a package that adds files to specific client architectures.
selftest.define("add packages client archs", function (options) {
var runTestWithArgs = function (clientType, args, port) {