I tried this script using --script:

  path = g.os_path_join(g.computeLeoDir(), 'tests', 'unitTest.leo')
  c2 = g.openWithFileName(path)
  c2.k.simulateCommand("run-selected-unit-tests-locally")

but it doesn't work because --script runs with the dummy gui.

This @script node in unitTests.leo works:

  import os
  def finder(c):
      p = g.findNodeAnywhere(c, "Active Unit Tests")
      c.selectPosition(p)
      c.redraw()
  if os.environ.get('LEO_TEST_AUTORUN'):
      from leo.core.leoQt import QtCore
      QtCore.QTimer.singleShot(2000, lambda c=c: finder(c))
      QtCore.QTimer.singleShot(
          4000,
          lambda c=c: c.k.simulateCommand("run-selected-unit-tests-locally")
      )

if (a) you have `@bool scripting-at-script-nodes = True` in
myLeoSettings.leo, and (b) you remove 
`@bool scriptingatscriptnodes = True` from unitTests.leo.  That
improper placement of that setting (only valid in (my)LeoSettings.leo)
seems to actually set the setting to False.

Then you can invoke it with something like:

DISPLAY=:10 LEO_TEST_AUTORUN=1 python launchLeo.py leo/test/unitTest.leo >log 
2>&1

and have the tests run without any interference.

For testing vanilla settings with `HOME=/tmp ...` you can always do
something like:

mkdir -p /tmp/.leo
cp enable_scripting_myLeoSettings.leo /tmp/.leo/myLeoSettings.leo
HOME=/tmp DISPLAY=:10 LEO_TEST_AUTORUN=1 python launchLeo.py \
    leo/test/unitTest.leo >log 2>&1

I know `@bool scriptingatscriptnodes = True` is in unitTest.leo to act
as a test, it could either be put in a different .leo outline and the
test run against that, or incorrect placement of that setting could
just result in a warning, and not a cancellation of the valid
`@bool scripting-at-script-nodes = True` in myLeoSettings.leo

So with one of those two options I think there's a much more
automateable / less intrusive way to run tests, at least on
multi-tasking OSes like Linux where a VNC server doesn't take over the
only display ;-)

Cheers -Terry

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to