mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Test which ensures that the global _ isn't compromised.
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.
This commit is contained in:
@@ -3,3 +3,14 @@ import { Meteor } from 'meteor/meteor';
|
||||
Meteor.startup(() => {
|
||||
Meteor.checkMeFromShell = "oky dok";
|
||||
});
|
||||
|
||||
// Create a global underscore variable which should be preserved,
|
||||
// not overriden by the special REPL `_` variable, when a command
|
||||
// is executed on the shell. The method will allow the test to call
|
||||
// back and confirm it's still set.
|
||||
_ = {_specialUnderscoreTestObject: true };
|
||||
Meteor.methods({
|
||||
"__meteor__/__self_test__/shell-tests/underscore"() {
|
||||
return typeof _ === "object" && Object.keys(_);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -18,6 +18,19 @@ selftest.define("meteor shell", function () {
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user