tidy-822209: Tidy-up speller

Better variable names: N->wordiLen, M->wordjLen and sorted_candidates->
sortedCandidtates
Also add protection against when a zero length list of names are passed
in.
asynctypes-685526: Add forceAsync and assertArgsAssigned

This adds 2 testing updates:

Requisition._assertArgsAssigned which is there to catch a bug which only
shows up with async testing. Somewhere in complete, we are dropping the
assignment from an arg. It could well have something to do with the
TODO line.

Also we're adding forceAsync to selections. Once we're done with the
fix above then we can move onto setting forceAsync to true and making
fixes there.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Fix issues with complete/addSpace

Previously addSpace assumed that it could force synchronous behaviour
which was a handy cheat, but this couldn't be sustained.
The onTextChange event was firing too early, not giving time for the
async parts to complete; now it is delayed properly.
The extra promise action going on in the complete function meant that we
needed to swap from a 'promise' variable to an 'outstanding' array.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: setup/post should be async

The setup and post functions should be able to return a promise to
indicate that the setup/post procedure is asynchronous. Also convert a
number of tests that should be using this (but are not) to using it.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Convert some exec tests to audit

Tests that use helpers.exec are likely to break when their parameters
are asynchronous or when we've flipped the 'forceAsync' flag.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Assume promises rather than test

Q.resolve will turn anything into a promise, but it's better to know
what you've got first. This clears up a couple of places where we used
Q.resolve transitionally, but no-longer need to.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Simplify test statuses

The asynchronous status wasn't used, and the pass/fail statuses were
used confusingly, when the real pass/fail measure is in the size of the
list of errors. Replace pass/fail with done.

Also introduce a toString for tests.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Enhance setInput test function

Previously, to test a sequence like "blah<UP><TAB>" we had to use
setInput followed by pressUp and pressTab, taking care to follow the
promises each time. Now setInput understands <BLAH> to mean a special
key sequence.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Enhance test generation

If we're setting non-EOL cursor position, then name the test better and
fix a bug where the completion promise was being dropped.
Also output a template for exec. We're expecting generated tests to be
edited, and it's better to provide something to be deleted rather than
force the user to remember how to do exec.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Don't trap rejected promises in _check

Let them flow up the chain of promises to the test harness which is
better placed to handle them.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Use promiseEach in audit

Nice simplification. We should think about promoting promiseEach more
widely.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Update logging output and docs

Various bits of console logging update from logs that are handy to have
in to work out what's up with the tests, to better ways to trap errors.
Also updates to TODOs, documentation

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Test runner fixes

Fix dropped promise return value, and a removal of the list of
outstanding function runs which helps us work out how things are getting
lost.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Update output from mock commands

Makes for better testing.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526: Test updates

Many test changes to use recent features of helpers and the test harness
At this point all the tests pass once more.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
asynctypes-685526:  Convert Help/Inputter tests to async

Now the unit tests for help and the inputter UI should work properly in
the face of asynchronous types. Only tooltip to go.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
Merge branch 'tidy-822209' into asynctypes-685526

Conflicts:
	lib/gcli/types/spell.js