mash_directive: check outdir existence, creation
ClosedPublic

Authored by lbrabec on Jun 27 2014, 10:32 AM.

Details

Summary

Existence of outdir is checked, raises directive error if it is existing file.
Outdir is created if doesn't exist.

Test Plan

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
lbrabec retitled this revision from to mash_directive: check outdir existence, creation.Jun 27 2014, 10:32 AM
lbrabec updated this object.
lbrabec edited the test plan for this revision. (Show Details)
lbrabec added a reviewer: kparal.
lbrabec edited the test plan for this revision. (Show Details)Jun 27 2014, 10:33 AM
lbrabec edited the test plan for this revision. (Show Details)
lbrabec edited the test plan for this revision. (Show Details)
lbrabec updated this revision to Diff 488.Jun 27 2014, 10:42 AM
  • polishing
kparal requested changes to this revision.Jun 27 2014, 2:23 PM

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?

This revision now requires changes to proceed.Jun 27 2014, 2:23 PM
lbrabec updated this revision to Diff 498.Jun 30 2014, 11:55 AM
  • polishing 2
kparal requested changes to this revision.Jun 30 2014, 1:52 PM

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.
https://pytest.org/latest/tmpdir.html

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().

This revision now requires changes to proceed.Jun 30 2014, 1:52 PM
lbrabec updated this revision to Diff 500.Jul 1 2014, 8:42 AM
  • polishing 3
kparal accepted this revision.Jul 1 2014, 10:03 AM

Looks good!

This revision is now accepted and ready to land.Jul 1 2014, 10:03 AM
lbrabec closed this revision.Jul 1 2014, 10:48 AM
lbrabec updated this revision to Diff 501.

Closed by commit rLTRN2294b06707e7 (authored by @lbrabec).