Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first draft of tool for output test formatting #16

Closed
wants to merge 4 commits into from

Conversation

jscotka
Copy link
Collaborator

@jscotka jscotka commented Apr 13, 2018

  • able to format output string for scheduler command:

Usages

generic

  • fmf-output --key test --formatstring "dir:{} test:{}" --value "data.get('path') or name" --value "data['test']"`
dir:fmf/examples/wget/download/test test:runtest.sh
dir:fmf/examples/wget/recursion/fast test:runtest.sh
dir:fmf/examples/wget/recursion/deep test:runtest.sh
dir:fmf/examples/wget/protocols/ftp test:runtest.sh
dir:fmf/examples/wget/protocols/http test:runtest.sh
dir:fmf/examples/wget/protocols/https test:runtest.sh

avocado command line

  • echo avocado run `fmf-output --key test --formatstring "{}/{}/{}" --value "getcwd()" --value "data.get('path') or name" --value "data['test']"` produces:
avocado run /home/jscotka/git/fmf/fmf/examples/wget/download/test/runtest.sh /home/jscotka/git/fmf/fmf/examples/wget/recursion/fast/runtest.sh /home/jscotka/git/fmf/fmf/examples/wget/recursion/deep/runtest.sh /home/jscotka/git/fmf/fmf/examples/wget/protocols/ftp/runtest.sh /home/jscotka/git/fmf/fmf/examples/wget/protocols/http/runtest.sh /home/jscotka/git/fmf/fmf/examples/wget/protocols/https/runtest.sh

beaker like line usage

  • echo bkr workflow-tomorrow `fmf-output --key test --formatstring "--task '{} /CoreOS/{}'" --value "data.get('params') or ''" --value "name"` produces:
bkr workflow-tomorrow --task ' /CoreOS/fmf/examples/wget/download/test' --task ' /CoreOS/fmf/examples/wget/recursion/fast' --task ' /CoreOS/fmf/examples/wget/recursion/deep' --task ' /CoreOS/fmf/examples/wget/protocols/ftp' --task ' /CoreOS/fmf/examples/wget/protocols/http' --task ' /CoreOS/fmf/examples/wget/protocols/https'

@coveralls
Copy link

coveralls commented Apr 13, 2018

Pull Request Test Coverage Report for Build 67

  • 54 of 55 (98.18%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 99.764%

Changes Missing Coverage Covered Lines Changed/Added Lines %
fmf/output_interpreter.py 54 55 98.18%
Totals Coverage Status
Change from base Build 58: -0.2%
Covered Lines: 423
Relevant Lines: 424

💛 - Coveralls

@psss
Copy link
Collaborator

psss commented Apr 17, 2018

That's a relly neat idea! Thanks, Honza. I think it makes sense to have this core functionality directly supported in the fmf command instead of introducing a new command line tool. I suggest to use the --format option for this:

fmf --format "name: {}" --value "node.name"

I also agree with moving the search/prune functionality out of the cli module. I'll work on merging/adjusting your changes soon. Just some hints for next pull requests:

http://fmf.readthedocs.io/en/latest/contribute.html

@jscotka
Copy link
Collaborator Author

jscotka commented Apr 17, 2018

@psss thanks a lot.
Yep, would be nice to move these functions like these prune, formatstring, inspect_dirs outside to base or utils or whatever, because if I'll use fmf as library in my tools, I'll do same functions inside my tools.

few notes here:

  • when I saw your code node.name it reminds me, that I would like to see some automatic key in node like self.data[id] = self.name then we'll be able to call there directly for example these keys like test path istead of inconsistency caused by that node.name is attribude of node class and other metadata are stored in data dictionary. second possibility is to add to Tree conscructor something like:
     for k, v in self.data.iteritems():
          setattr(self, k, v)
  • node is some hidden internal variable, thats why I've done there name = node.name and data = node.data because at least name and data are variables in tree class, node is just local variable in loop
  • hidden feature of using dictionary data is that we can use then data['key'] syntax, or data.get('key', '') what allows me ignore when item is missing and assign some default value what allows me then in --value use syntax like data.get('path') or name for example

@psss psss closed this in a2a1f0a Apr 17, 2018
@psss
Copy link
Collaborator

psss commented Apr 17, 2018

Thanks, Honza. Using data dictionary makes sense. I've moved the support for custom formatting to cli & base modules and merged to master. Please, check if everything works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants