Fixing the build to run python tests

Fred Wright fw at
Wed Nov 29 23:07:51 UTC 2017

On Wed, 29 Nov 2017, Ian Bruene via devel wrote:
> On 11/29/2017 04:17 PM, Hal Murray via devel wrote:
> > That link lets you test python code using the new libraries.
> >
> > In a previous version of that code, the link was in ntpclients and you could
> > run things by cd-ing there.  Now the link is in $build/main/ntpclients so you
> > have to cd there.  Are you doing that?

You don't have to literally cd there - using any path that points to the
"build copy" of the program or test works.

> This problem is only with the tests which need to access the python ntp
> modules, not the sutff in ntpclients/. Once the build is complete
> everything works just fine. And this is happening within the build
> script: no cd'ing allowed as far as I know.

Anything that needs the compiled extension can't possibly work without
building first, anyway.  And although one could theoretically run tests
based solely on pure Python code without building, it's not worth the
hassle to special-case that.  None of the C tests runs without building

The real problem with fitting the tests into waf's testing framework is
that the latter just plain doesn't handle Python tests properly (and you
can find grumbling online about that).  Fixing this requires figuring out
why it doesn't work and coming up with some sort of workaround.

In the meantime, you can make do with:

$ ./waf configure && ./waf build && for t in build/main/tests/pylib/test_*.py; do $t || break; done

BTW, all the waf code is readable once it's been run, in the .waf-...
directory.  You can even set breakpoints in it if you first break at the
Scripting.waf_entry_point() call in ./waf (currently line 165, but that
could change).

Fred Wright

More information about the devel mailing list