mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Declare _FooTest symbols as testOnly; they are only visible to tests.
They are visible to *all* tests, not just the package's own tests.
This commit is contained in:
@@ -6,7 +6,7 @@ Package.describe({
|
||||
Package.on_use(function (api) {
|
||||
api.use(['json', 'underscore']);
|
||||
api.exportSymbol('EJSON');
|
||||
api.exportSymbol('_EJSONTest');
|
||||
api.exportSymbol('_EJSONTest', {testOnly: true});
|
||||
api.add_files('ejson.js', ['client', 'server']);
|
||||
api.add_files('base64.js', ['client', 'server']);
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ Npm.depends({mailcomposer: "0.1.15", simplesmtp: "0.1.25", "stream-buffers": "0.
|
||||
Package.on_use(function (api) {
|
||||
api.use('underscore', 'server');
|
||||
api.exportSymbol('Email', 'server');
|
||||
api.exportSymbol('_EmailTest', 'server');
|
||||
api.exportSymbol('_EmailTest', 'server', {testOnly: true});
|
||||
api.add_files('email.js', 'server');
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Package.on_use(function (api) {
|
||||
api.exportSymbol('DDP');
|
||||
api.exportSymbol('DDPServer', 'server');
|
||||
|
||||
api.exportSymbol('_LivedataTest');
|
||||
api.exportSymbol('_LivedataTest', {testOnly: true});
|
||||
|
||||
// Transport
|
||||
api.use('reload', 'client');
|
||||
|
||||
@@ -26,7 +26,7 @@ Package.on_use(function (api) {
|
||||
// Allow us to detect 'autopublish', and publish collections if it's loaded.
|
||||
api.use('autopublish', 'server', {weak: true});
|
||||
|
||||
api.exportSymbol('_MongoLivedataTest', 'server');
|
||||
api.exportSymbol('_MongoLivedataTest', 'server', {testOnly: true});
|
||||
|
||||
api.add_files('mongo_driver.js', 'server');
|
||||
api.add_files('local_collection_driver.js', ['client', 'server']);
|
||||
|
||||
@@ -9,7 +9,7 @@ Package.on_use(function (api) {
|
||||
api.use(['underscore', 'service-configuration'], 'server');
|
||||
|
||||
api.exportSymbol('Oauth');
|
||||
api.exportSymbol('_OauthTest', 'server');
|
||||
api.exportSymbol('_OauthTest', 'server', {testOnly: true});
|
||||
|
||||
api.add_files('oauth_client.js', 'client');
|
||||
api.add_files('oauth_server.js', 'server');
|
||||
|
||||
@@ -11,7 +11,7 @@ Package.on_use(function (api) {
|
||||
api.use('http', 'server');
|
||||
|
||||
api.exportSymbol('OAuth1Binding', 'server');
|
||||
api.exportSymbol('_OAuth1Test', 'server');
|
||||
api.exportSymbol('_OAuth1Test', 'server', {testOnly: true});
|
||||
|
||||
api.add_files('oauth1_binding.js', 'server');
|
||||
api.add_files('oauth1_server.js', 'server');
|
||||
|
||||
@@ -9,7 +9,7 @@ Package.on_use(function (api) {
|
||||
// Package.webapp and only after initial load.
|
||||
api.use('webapp', 'server', {unordered: true});
|
||||
api.exportSymbol('RoutePolicy', 'server');
|
||||
api.exportSymbol('_RoutePolicyTest', 'server');
|
||||
api.exportSymbol('_RoutePolicyTest', 'server', {testOnly: true});
|
||||
api.add_files('routepolicy.js', 'server');
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Package.on_use(function (api) {
|
||||
'client');
|
||||
|
||||
api.exportSymbol('Spark', 'client');
|
||||
api.exportSymbol('_SparkTest', 'client');
|
||||
api.exportSymbol('_SparkTest', 'client', {testOnly: true});
|
||||
|
||||
api.add_files(['spark.js', 'patch.js', 'convenience.js',
|
||||
'utils.js'], 'client');
|
||||
|
||||
@@ -462,8 +462,8 @@ var bannerPadding = function (bannerWidth) {
|
||||
// - sourcePath: path to use in error messages
|
||||
// - sourceMap: an optional source map (as string) for the input file
|
||||
//
|
||||
// declaredExports: an array of symbols that the module exports. null
|
||||
// if our slice isn't allowed to have exports.
|
||||
// declaredExports: an array of symbols that the module exports. null if our
|
||||
// slice isn't allowed to have exports. Symbols are {name,testOnly} pairs.
|
||||
//
|
||||
// useGlobalNamespace: make the top level namespace be the same as the
|
||||
// global namespace, so that symbols are accessible from the
|
||||
|
||||
@@ -399,7 +399,7 @@ _.extend(Slice.prototype, {
|
||||
rootOutputPath: self.pkg.serveRoot,
|
||||
arch: self.arch,
|
||||
fileOptions: fileOptions,
|
||||
declaredExports: self.declaredExports,
|
||||
declaredExports: _.pluck(self.declaredExports, 'name'),
|
||||
read: function (n) {
|
||||
if (n === undefined || readOffset + n > contents.length)
|
||||
n = contents.length - readOffset;
|
||||
@@ -493,7 +493,7 @@ _.extend(Slice.prototype, {
|
||||
"/packages/" + self.pkg.name +
|
||||
(self.sliceName === "main" ? "" : ("." + self.sliceName)) + ".js",
|
||||
name: self.pkg.name || null,
|
||||
declaredExports: self.declaredExports,
|
||||
declaredExports: _.pluck(self.declaredExports, 'name'),
|
||||
jsAnalyze: jsAnalyze
|
||||
});
|
||||
|
||||
@@ -517,14 +517,14 @@ _.extend(Slice.prototype, {
|
||||
|
||||
self.packageVariables = [];
|
||||
var packageVariableNames = {};
|
||||
_.each(self.declaredExports, function (name) {
|
||||
if (_.has(packageVariableNames, name))
|
||||
_.each(self.declaredExports, function (symbol) {
|
||||
if (_.has(packageVariableNames, symbol.name))
|
||||
return;
|
||||
self.packageVariables.push({
|
||||
name: name,
|
||||
export: true
|
||||
name: symbol.name,
|
||||
export: symbol.testOnly? "tests" : true
|
||||
});
|
||||
packageVariableNames[name] = true;
|
||||
packageVariableNames[symbol.name] = true;
|
||||
});
|
||||
_.each(results.assignedVariables, function (name) {
|
||||
if (_.has(packageVariableNames, name))
|
||||
@@ -580,8 +580,9 @@ _.extend(Slice.prototype, {
|
||||
if (! otherSlice.isBuilt)
|
||||
throw new Error("dependency wasn't built?");
|
||||
_.each(otherSlice.packageVariables, function (symbol) {
|
||||
// XXX implement test-only exports
|
||||
if (symbol.export)
|
||||
// Slightly hacky implementation of test-only exports.
|
||||
if (symbol.export === true ||
|
||||
(symbol.export === "tests" && self.sliceName === "tests"))
|
||||
imports[symbol.name] = otherSlice.pkg.name;
|
||||
});
|
||||
});
|
||||
@@ -1586,13 +1587,22 @@ _.extend(Package.prototype, {
|
||||
//
|
||||
// @param symbols String (eg "Foo") or array of String
|
||||
// @param where 'client', 'server', or an array of those
|
||||
exportSymbol: function (symbols, where) {
|
||||
// @param options 'testOnly', boolean.
|
||||
exportSymbol: function (symbols, where, options) {
|
||||
if (role === "test") {
|
||||
buildmessage.error("You cannot export symbols from a test.",
|
||||
{ useMyCaller: true });
|
||||
// recover by ignoring
|
||||
return;
|
||||
}
|
||||
// Support `api.exportSymbol("FooTest", {testOnly: true})` without
|
||||
// where.
|
||||
if (_.isObject(where) && !_.isArray(where) && !options) {
|
||||
options = where;
|
||||
where = null;
|
||||
}
|
||||
options = options || {};
|
||||
|
||||
symbols = toArray(symbols);
|
||||
where = toWhereArray(where);
|
||||
|
||||
@@ -1605,7 +1615,7 @@ _.extend(Package.prototype, {
|
||||
return;
|
||||
}
|
||||
_.each(where, function (w) {
|
||||
exports[w].push(symbol);
|
||||
exports[w].push({name: symbol, testOnly: !!options.testOnly});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user