Existence of outdir is checked, raises directive error if it is existing file.
Outdir is created if doesn't exist.
Details
- Reviewers
kparal - Commits
- rLTRN2294b06707e7: mash_directive: check outdir existence and creation
Used this yaml:
name: mash desc: test mash directive maintainer: lbrabec input: args: - arch task: - name: test mash rpmdir/outdir functionality mash: rpmdir: rpmdir outdir: outdir arch: ${arch}
$ python runtask.py -a i386 <above yml>
rpmdir should contain rpms.
Diff Detail
- Repository
- rLTRN libtaskotron
- Lint
Lint Skipped - Unit
Unit Tests Skipped
I wonder, could you also please write a functional test that would try whether this output dir creation functionality works?
libtaskotron/directives/mash_directive.py | ||
---|---|---|
86–87 | This is the old documentation, please pull from develop and rebase it. Then adjust the outdir documentation to state that the dir will be created automatically if not present. | |
171 | I'd put something like # create outdir if it doesn't exist above this line. It's much easier to skim the code then. | |
172–176 | I don't understand why this code is needed. The python_utils.makedirs() function is a modified os.makedirs() to work like mkdir -p in bash (except the parent creation). I think the code in the else block should be fully sufficient - the error will be thrown only if the dir can't be created, but not if it is already present. Maybe it's better to explicitly call python_utils.makedirs() instead of makedirs() so that it's clear this is our modified version and prior checks for dir existence are not required? |
A few inconsequential requests...
libtaskotron/directives/mash_directive.py | ||
---|---|---|
37–38 | If I can nitpick, I'd write it as ``outdir`` | |
86–87 | Ouch, by some mistake this docstring was not deleted when DOCUMENTATION and EXAMPLES were added. Please remove this whole docstring, thanks. | |
testing/functest_mash_directive.py | ||
9–10 | I find a bit confusing to import something named and_, and to a lesser extent even SimpleRpmBuild. For non-descriptive names, or for less frequent modules, please consider importing the whole module and then using e.g. operator.and_. The code will get more readable. Of course, if you need to use it on every second line, it makes sense to try to have the name shorter. If you need to use it just once or twice, however... Btw, some of these names don't seem to be used at all, says pyflakes. | |
75 | Instead of using tempfile module, could you please rather use tmpdir fixture? Not just here, in the whole module. It has many advantages over standard tempfile module. We can easily control where the files are created and the files/dirs are kept there only for a limited time, then they're deleted by pytest. Also, it's very easy to find these files and debug the unit test when something goes wrong. Have a look at other functional tests how to use tmpdir fixture. | |
87 | According to documentation it seems that isdir() implies exists(). |
If I can nitpick, I'd write it as