Fixing the build to run python tests
Ian Bruene
ianbruene at gmail.com
Wed Nov 29 21:59:25 UTC 2017
First issue (blocker)
I have succeeded in getting the unit testing scripts for python code to
run as part of the build on my machine, however when uploaded to GitLab
the pipelines fail with an import error in the test scripts. The test
modules cannot import the library modules they are meant to test.
The cause of this issue is that the python libraries are stored in
pylib/ but installed (and referenced in the code) as ntp/. Previously
this caused import problems that were solved when someone added code to
create a symlink from ntp/ to pylib/ at the end of the build process.
When run by the pipeline this symlink is not in place, resulting in the
error. When I delete the build/ folder from my repo and run the build it
errors out with a different import error (probably gets farther because
I have an installed copy it can piggyback off of), but then a subsequent
clean configure build succeeds.
Adding the pytest_paths argument to the build script does not - and
cannot - work because of the "pylib" vs "ntp" difference.
I attempted to snip the code from afterparty() that creates the symlinks
and stick it in build() before the tests are run. It errored in ways I
do not understand.
Though I understand the build system far better than I did a week ago I
am still mostly poking it while trying to not to blow it up. Which leads
nicely into the next problem...
Second issue (non-blocker, but ugly)
In order to run unit tests on python code the "pytest" waf module is
required. Attempting to load it normally failed, leading me to believe
that it was not included in the non-human-readable waf code. After
manually downloading the relevant file from the waf repo I tried to
place it in the directory where it should go in theory, resulting in
failed imports for everything else that has that import path (but is
really imported from the archive). I also tried to place in in
wafhelpers, which failed. Currently in the MR for the build changes
pytest.py sits in the top level ntpsec/ directory where it works, but
this kind of sloppiness is not how the build should be arranged.
I do not know how to "recompile" waf to include different modules, I
don't know the beginnings of what I don't know, and I'm not sure that I
would do it if I did know. Someone with Official Build Wrangling status
needs to take a look at this.
--
/"In the end; what separates a Man, from a Slave? Money? Power? No. A
Man Chooses, a Slave Obeys."/ -- Andrew Ryan
/"Utopia cannot precede the Utopian. It will exist the moment we are fit
to occupy it."/ -- Sophia Lamb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20171129/c8055d1b/attachment.html>
More information about the devel
mailing list