Files
meteor/tools/cli
ekatek ef13ed9926 use selftest to run tests against galaxy
UX Changes:
  - Added a `--galaxy` option to selftest to run tests against galaxy.
    Self-test will NOT run those tests without this option. Self-test will not run any
    other tests WITH this option.

    The motivation here is two-fold:
     - We want to make it easy to use self-test to test Galaxy without running a bunch
       of extra tests. At least, we want this right now, while Galaxy is still in development.

     - Galaxy is currently pretty unstable&slow; we don't want to run our regular test suite against
       Galaxy all the time and slow down the tool development process. Additionally, the environment
       variables required by Galaxy are a pain to set.

    This is a TEMPORARY situation. Eventually, we will want to either merge the two tests together
    (especially once we rotate out Mother...) or we will have a separate unrelated Galaxy test suite
    and move a lot of this stuff here. With time, it will also become more obvious what a better default
    (run Galaxy tests always/run Galaxy tests never/run non-Galaxy-specific tests against Galaxy) is.

    The changes should be pretty self-contained.

 - Added some number of environment variables to use with --galaxy tests. This is a bit complicated
   and will be documented in
     https://mdg.hackpad.com/GalaxyECS-Admin-tasks-RTXJ5YW8pDv#:h=Testing-Galaxy-with-selftest.

Walkthrough:
    - galaxy-utls.js contains basic utils for running Galaxy tests. Use environment variables, etc.

    - galaxy.js contains the acutal test

    - simple-app is an app that responds to HTTP requests and serves some html that we can test to be running

    - minor changes to config.js to allow overriding of the domain name

    - minor changes to auth.js to allow us to automatically login as the (new) test user and use that
      login to start a DDP collection.

    - move a function out of deploy-settings.js into test-utils.js

    - some minor additions to test-utils.js

Reviewed in https://github.com/meteor/meteor/pull/4997.
2015-08-26 19:06:13 -07:00
..
2015-08-10 11:24:23 -07:00

CLI

Files in this folder define the common framework for defining and parsing CLI commands, options and properties such as inApp or inPackage.

It is encouraged to split out theme sharing commands into separate files.

An example of a command:

main.registerCommand({
  name: 'some-command',
  requiresRelease: false,
  requiresApp: true,
  // requiresPackage: true,
  // requiresAppOrPackage: true,
  pretty: true, // optional
  minArgs: 1, // optional
  maxArgs: 10, // optional
  options: {
    'long-option': { type: Boolean, short: 's', default: true, required: true },
    'with-string': { type: String, short: 'w' }
  }
}, function (options) {
  var {appDir, packageDir, args} = options;
  var longOption = options['long-option'];
  var withString = options['with-string'];
  ...
});

This command will handle the following examples:

meteor some-command --long-option
meteor some-command -s
meteor some-command -s --with-string "some value"
meteor some-command -s -w "some value"

Note: don't pick a short key for an option unless it is very common to use it. The commands parser makes sure the same short key for an option is used consistently for the same kind of option across all commands. So two commands A and B can share a short option "c" only if it stands for the same long option in both cases.

Catalog refresh policy

You might notice that some commands are marked to never refresh the catalog. This is useful to make the command fast, if the command doesn't involve any network communication to the package server, it might be a good idea to forbid the preemtive refresh:

main.registerCommand({
  ...
  catalogRefresh: new catalog.Refresh.Never()
});

Command return code

For some reason there are two ways to terminate the command with a non-standard exit code (non-zero, unix process exit code).

First way is just the return value of the command function, which should be a number.

The second way is to throw a special kind of exception:

main.registerCommand({...}, function (options) {
  throw new main.ExitWithCode(2);
})

In case of additional options check, you can throw another special exception to show the help text for the command:

main.registerCommand({...}, function (options) {
  if (options.bla === 'bad-value')
    throw new main.ShowUsage;
})

There is also main.WaitForExit used for terminating after the subprocesses are done. (XXX more info)

help.txt

The help.txt file contains all the information printed to the user when the meteor help command is run. It has its own syntax where every command is separated by a marker >>> with the name of the command.

Commands are parsed so the help text for an individual command could be separated from the rest.

Sadly, these commands need to be redocumented in the docs app as well. The docs text is not shared between these two places, yet.

Admin commands

Given that self-test is the only reliable way to test code in Meteor Tool, you might need to create special "admin" commands. Since "admin" commands don't show up in the help text, this namespace is abused to store all sorts of one-of commands to run in automated and manual tests.