mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
As demonstrated in https://github.com/meteor/meteor/issues/9276.
This test wouldn't have caught the regression in the previous solution
since the lack of a TTY in the `self-test` test harness caused the tests
themselves to take the path through `shell-server`'s `evaluateAndExit`
logic, which didn't use the `global` scope in the same way as the
interactive shell. That is no longer the case as of e0682c553d.
68 lines
2.0 KiB
JavaScript
68 lines
2.0 KiB
JavaScript
var selftest = require('../tool-testing/selftest.js');
|
|
var Sandbox = selftest.Sandbox;
|
|
|
|
selftest.define("meteor shell", function () {
|
|
var s = new Sandbox();
|
|
s.createApp("meteor-shell-test", "shell");
|
|
s.cd("meteor-shell-test");
|
|
|
|
var server = s.run();
|
|
server.waitSecs(60);
|
|
server.match("App running at");
|
|
|
|
var shell = s.run("shell");
|
|
// First try a simple one-line expression.
|
|
shell.write("({server:Meteor.isServer})\n");
|
|
shell.proc.stdin.end();
|
|
shell.waitSecs(10);
|
|
shell.match('{"server":true}');
|
|
shell.expectExit(0);
|
|
|
|
shell = s.run("shell");
|
|
// Make sure that the special Node REPL _ variable is not stomping on any
|
|
// global `_` (i.e. Underscore) since the default `repl` behavior sets the
|
|
// special variable `_` to the result of the last operation. This method
|
|
// call to the server will make sure our special `_` remains intact after
|
|
// the shell is launched.
|
|
shell.write(
|
|
"Meteor.call('__meteor__/__self_test__/shell-tests/underscore')\n");
|
|
shell.proc.stdin.end();
|
|
shell.waitSecs(10);
|
|
shell.match('["_specialUnderscoreTestObject"]');
|
|
shell.expectExit(0);
|
|
|
|
shell = s.run("shell");
|
|
// Now try with a bunch of newlines in the input.
|
|
shell.write("500+\n4000\n+60\n\n+\n7\n");
|
|
shell.proc.stdin.end();
|
|
shell.waitSecs(10);
|
|
shell.match("4567");
|
|
shell.expectExit(0);
|
|
|
|
shell = s.run("shell");
|
|
// Now use the shell to make the server output something.
|
|
shell.write('console.log("oyez")\n');
|
|
shell.proc.stdin.end();
|
|
shell.waitSecs(10);
|
|
server.match("oyez");
|
|
shell.expectExit(0);
|
|
|
|
shell = s.run("shell");
|
|
// Now check something set by the test app.
|
|
shell.write('Meteor.checkMeFromShell\n');
|
|
shell.proc.stdin.end();
|
|
shell.waitSecs(10);
|
|
shell.match("oky dok");
|
|
shell.expectExit(0);
|
|
|
|
shell = s.run("shell");
|
|
// Now check importing a module
|
|
shell.write('import { Meteor } from "meteor/meteor"\n');
|
|
shell.proc.stdin.end();
|
|
shell.waitSecs(10);
|
|
shell.match("undefined");
|
|
shell.expectExit(0);
|
|
|
|
server.stop();
|
|
});
|