From 957729c8cefced583fff43af0b7508ea1a5ef1d5 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Fri, 17 May 2013 12:35:35 -0700 Subject: [PATCH] Get run-tools-tests.sh passing. In addition to minor "make the tests match the code" changes, there's also: - missing require('tar') in tarball download code - fix an fd leak in the bundler that was causing EMFILE on mac - switch run.js to listening for 'exit' to 'close' so that the end of stdout/err can be read - some concerningly necessary deletions of .build directories Also, the version of cli-test.sh that runs against a fixed release is disabled, since we're not building releases with the new package format for now. --- scripts/cli-test.sh | 5 +++-- scripts/run-tools-tests.sh | 4 +++- tools/files.js | 1 + tools/packages.js | 18 +++++++++++++----- tools/run.js | 2 +- tools/tests/test_bundler_npm.js | 21 +++++++++++++++++---- tools/tests/test_bundler_options.js | 14 +++++++------- 7 files changed, 45 insertions(+), 20 deletions(-) diff --git a/scripts/cli-test.sh b/scripts/cli-test.sh index 2cdc5c8fa5..ccf1337e5f 100755 --- a/scripts/cli-test.sh +++ b/scripts/cli-test.sh @@ -244,6 +244,7 @@ if (Meteor.isServer) { EOF $METEOR -p $PORT --settings='settings.json' --once >> $OUTPUT +rm settings.js # prepare die.js so that we have a server that loads packages and dies @@ -257,8 +258,6 @@ echo "... local-package-sets -- new package" mkdir -p "$TEST_TMPDIR/local-packages/a-package-named-bar/" cat > "$TEST_TMPDIR/local-packages/a-package-named-bar/package.js" < "$TEST_TMPDIR/local-packages/a-package-named-bar/call_gcd.js" < Exited from signal: ' + signal}); } else { diff --git a/tools/tests/test_bundler_npm.js b/tools/tests/test_bundler_npm.js index c00fd67606..7620ed399e 100644 --- a/tools/tests/test_bundler_npm.js +++ b/tools/tests/test_bundler_npm.js @@ -107,9 +107,10 @@ var _assertCorrectPackageNpmDir = function(deps) { var _assertCorrectBundleNpmContents = function(bundleDir, deps) { // sanity check -- main.js has expected contents. assert.strictEqual(fs.readFileSync(path.join(bundleDir, "main.js"), "utf8").trim(), - "require('./programs/server/server.js');"); + "require('./programs/server/boot.js');"); - var bundledPackageNodeModulesDir = path.join(bundleDir, 'programs', 'server', 'npm', 'test-package'); + var bundledPackageNodeModulesDir = path.join( + bundleDir, 'programs', 'server', 'npm', 'test-package', 'main', 'node_modules'); // bundle actually has the npm modules _.each(deps, function(version, name) { @@ -162,6 +163,10 @@ assert.doesNotThrow(function () { var nodeModulesDir = path.join(testPackageDir, ".npm", "node_modules"); assert(fs.existsSync(path.join(nodeModulesDir))); files.rm_recursive(nodeModulesDir); + // We also have to delete the .build directory or else we won't rebuild at + // all. + // XXX this seems wrong! + files.rm_recursive(path.join(testPackageDir, ".build")); assert(!fs.existsSync(path.join(nodeModulesDir))); lib.refresh(); @@ -203,6 +208,10 @@ assert.doesNotThrow(function () { var nodeModulesMimeDir = path.join(testPackageDir, ".npm", "node_modules", "mime"); assert(fs.existsSync(path.join(nodeModulesMimeDir))); files.rm_recursive(nodeModulesMimeDir); + // We also have to delete the .build directory or else we won't rebuild at + // all. + // XXX this seems wrong! + files.rm_recursive(path.join(testPackageDir, ".build")); assert(!fs.existsSync(path.join(nodeModulesMimeDir))); lib.refresh(); @@ -227,8 +236,12 @@ assert.doesNotThrow(function () { updateTestPackage({gcd: '0.0.0', mime: '0.1.2'}); var tmpOutputDir = tmpDir(); var result = bundler.bundle(appWithPackageDir, tmpOutputDir, {nodeModulesMode: 'skip', releaseStamp: 'none', library: lib}); - assert.strictEqual(result.errors.length, 1); - assert(/version not found/.test(result.errors[0])); + assert(result.errors); + var job = _.find(result.errors.jobs, function (job) { + return job.title === "building package `test-package`"; + }); + assert(job); + assert(/mime version 0.1.2 is not available/.test(job.messages[0].message)); _assertCorrectPackageNpmDir({gcd: '0.0.0', mime: '1.2.8'}); // shouldn't've changed }); diff --git a/tools/tests/test_bundler_options.js b/tools/tests/test_bundler_options.js index 5484097c60..cc506a7e5c 100644 --- a/tools/tests/test_bundler_options.js +++ b/tools/tests/test_bundler_options.js @@ -22,7 +22,7 @@ assert.doesNotThrow(function () { // sanity check -- main.js has expected contents. assert.strictEqual(fs.readFileSync(path.join(tmpOutputDir, "main.js"), "utf8").trim(), - "require('./programs/server/server.js');"); + "require('./programs/server/boot.js');"); // no top level node_modules directory assert(!fs.existsSync(path.join(tmpOutputDir, "programs", "server", "node_modules"))); @@ -46,7 +46,7 @@ assert.doesNotThrow(function () { // sanity check -- main.js has expected contents. assert.strictEqual(fs.readFileSync(path.join(tmpOutputDir, "main.js"), "utf8").trim(), - "require('./programs/server/server.js');"); + "require('./programs/server/boot.js');"); // verify that contents are not minified var appHtml = fs.readFileSync(path.join(tmpOutputDir, "programs", "client", "app.html")); @@ -66,11 +66,11 @@ assert.doesNotThrow(function () { // sanity check -- main.js has expected contents. assert.strictEqual(fs.readFileSync(path.join(tmpOutputDir, "main.js"), "utf8").trim(), - "require('./programs/server/server.js');"); + "require('./programs/server/boot.js');"); // verify that tests for the meteor package are included var appHtml = fs.readFileSync(path.join(tmpOutputDir, "programs", "client", "app.html")); - assert(/src=\"\/package-tests\/meteor.js/.test(appHtml)); + assert(/src=\"\/packages\/meteor\.tests\.js/.test(appHtml)); }); console.log("nodeModules: 'copy'"); @@ -81,7 +81,7 @@ assert.doesNotThrow(function () { // sanity check -- main.js has expected contents. assert.strictEqual(fs.readFileSync(path.join(tmpOutputDir, "main.js"), "utf8").trim(), - "require('./programs/server/server.js');"); + "require('./programs/server/boot.js');"); // node_modules directory exists and is not a symlink assert(!fs.lstatSync(path.join(tmpOutputDir, "programs", "server", "node_modules")).isSymbolicLink()); // node_modules contains fibers @@ -96,7 +96,7 @@ assert.doesNotThrow(function () { // sanity check -- main.js has expected contents. assert.strictEqual(fs.readFileSync(path.join(tmpOutputDir, "main.js"), "utf8").trim(), - "require('./programs/server/server.js');"); + "require('./programs/server/boot.js');"); // node_modules directory exists and is a symlink assert(fs.lstatSync(path.join(tmpOutputDir, "programs", "server", "node_modules")).isSymbolicLink()); // node_modules contains fibers @@ -104,6 +104,6 @@ assert.doesNotThrow(function () { // package node_modules directory also a symlink assert(fs.lstatSync(path.join( - tmpOutputDir, "programs", "server", "npm", "livedata")) + tmpOutputDir, "programs", "server", "npm", "livedata", "main", "node_modules")) .isSymbolicLink()); });