mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Bundler option change: testPackages instead of include_tests
Also, eliminated some dead code. This should be the last bundler change necessary for implementing `meteor test-packages`
This commit is contained in:
committed by
David Glasser
parent
87024ac5fe
commit
99f80949ac
@@ -125,19 +125,6 @@ var PackageInstance = function (pkg, bundle) {
|
||||
return _.map(ret, function (x) {return "." + x;});
|
||||
},
|
||||
|
||||
// Add the tests for another package. Mostly for internal
|
||||
// use. Like use in that it can take either the package name or a
|
||||
// package object, and can take an array.
|
||||
include_tests: function (names) {
|
||||
if (!(names instanceof Array))
|
||||
names = [names];
|
||||
|
||||
_.each(names, function (name) {
|
||||
var pkg = packages.get(bundle.manifest, name);
|
||||
self.bundle.include_tests(pkg);
|
||||
});
|
||||
},
|
||||
|
||||
// Report an error. It should be a single human-readable
|
||||
// string. If any errors are reported, the bundling is considered
|
||||
// to have failed.
|
||||
@@ -228,6 +215,9 @@ var Bundle = function () {
|
||||
// Packages that have had tests included. Map from package id to instance
|
||||
self.tests_included = {};
|
||||
|
||||
// release manifest
|
||||
self.manifest = null;
|
||||
|
||||
// map from environment, to list of filenames
|
||||
self.js = {client: [], server: []};
|
||||
|
||||
@@ -394,8 +384,9 @@ _.extend(Bundle.prototype, {
|
||||
pkg.on_use_handler(inst.api, where);
|
||||
},
|
||||
|
||||
include_tests: function (pkg) {
|
||||
includeTests: function (packageName) {
|
||||
var self = this;
|
||||
var pkg = packages.get(self.manifest, packageName);
|
||||
if (self.tests_included[pkg.id])
|
||||
return;
|
||||
self.tests_included[pkg.id] = true;
|
||||
@@ -718,7 +709,8 @@ _.extend(Bundle.prototype, {
|
||||
* 'symlink' : symlink from a prebuild local installation. used
|
||||
* by `meteor run`
|
||||
*
|
||||
* - include_tests : include tests for the project
|
||||
* - testPackages : array of package names whose tests should be included
|
||||
* in this bundle
|
||||
*
|
||||
* - versionOverride : (for tests) a meteor release version to use
|
||||
* instead of reading from .meteor/version
|
||||
@@ -747,10 +739,10 @@ exports.bundle = function (app_dir, output_path, options) {
|
||||
bundle.use(app);
|
||||
|
||||
// Include tests if requested
|
||||
if (options.include_tests) {
|
||||
// in the future, let use specify the driver, instead of hardcoding?
|
||||
bundle.use(packages.get(manifest, 'test-in-browser'));
|
||||
bundle.include_tests(app);
|
||||
if (options.testPackages) {
|
||||
_.each(options.testPackages, function(packageName) {
|
||||
bundle.includeTests(packageName);
|
||||
});
|
||||
}
|
||||
|
||||
// Minify, if requested
|
||||
|
||||
@@ -67,6 +67,23 @@ assert.doesNotThrow(inFiber(function () {
|
||||
assert(!(/src=\"\/[0-9a-f]{40,40}.js\"/.test(appHtml)));
|
||||
assert(/src=\"\/packages\/meteor/.test(appHtml));
|
||||
assert(/src=\"\/packages\/deps/.test(appHtml));
|
||||
// verify that tests aren't included
|
||||
assert(!(/src=\"\/packages\/meteor\/url_tests.js/.test(appHtml)));
|
||||
}));
|
||||
|
||||
// versioned app, nodeModules: 'skip', noMinify, testPackages: ['meteor']
|
||||
assert.doesNotThrow(inFiber(function () {
|
||||
var tmpOutputDir = tmpDir();
|
||||
var errors = bundler.bundle(
|
||||
versionedAppDir, tmpOutputDir, {nodeModulesMode: 'skip', noMinify: true, testPackages: ['meteor']});
|
||||
assert.strictEqual(errors, undefined);
|
||||
|
||||
// sanity check -- main.js has expected contents.
|
||||
assert.strictEqual(fs.readFileSync(path.join(tmpOutputDir, "main.js"), "utf8").trim(),
|
||||
"require(require('path').join(__dirname, 'server', 'server.js'));");
|
||||
// verify that tests for the meteor package are included
|
||||
var appHtml = fs.readFileSync(path.join(tmpOutputDir, "app.html"));
|
||||
assert(/src=\"\/packages\/meteor\/url_tests.js/.test(appHtml));
|
||||
}));
|
||||
|
||||
// versioned app, nodeModules: 'copy'
|
||||
|
||||
Reference in New Issue
Block a user