Running a unit test locally, without exiting Leo, saves a lots of time.
It's *much faster* than having to load unitTest.leo or even a small .leo
file.
The question is, how to use the newest code? imp.reload often doesn't
work. But just yesterday I saw a way that usually *does* work. Clone the
code under development and put it under an @test node. The script in the
@test node uses *@others* to gain access to the code, *not* an import.
For instance, here is the @test node I use to develop the new javascript
importer:
g.cls()
p1 = p.copy()
if c.isChanged():
c.save()
import leo.plugins.importers.basescanner as basescanner
@others
scanner = JavaScriptScanner(c.importCommands, atAuto = False)
h = '@ignore js-test'
p = g.findNodeAnywhere(c, h)
if p:
while p.firstChild():
p.firstChild().doDelete()
else:
p = c.insertHeadline()
p.h = h
c.selectPosition(p)
fn = r'c:\prog\jQuery-short2.js'
s = open(fn, 'r').read()
print('Sources..\n\n%s\n\n' % s)
scanner.scan(s, p)
c.selectPosition(p1)
c.redraw()
print('done')
To repeat, the code under test is a child of this node, so the script uses
@others to gain access to it. It's super fast.
There is another happy consequence of this Aha. There is no longer any
great need *ever* to run unit tests externally, so I can use the following
key bindings:
run-selected-unit-tests-locally = Alt-4
run-marked-unit-tests-locally = Alt-5
run-all-unit-tests-locally = Alt-6
This is much easier to remember--I don't have to remember which bindings
apply to external tests and which to local. It's easy to remember that
Alt-4 runs the fewest tests, Alt-5 runs more tests and Alt-6 runs all the
tests.
You could call this an extension of the "stupendous Aha".
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.