Add support for running a command before tests

Review Request #1179 — Created Oct. 17, 2014 and submitted

dturner-tw
pants
5c32301...
pants-reviews
ity, jsirois, lahosken, patricklaw, peiyu

Add support for running a command before tests.

This depends on https://rbcommons.com/s/twitter/r/1177/

Ran new test.

  • 0
  • 0
  • 4
  • 1
  • 5
Description From Last Updated
LA
  1. I can't figure out how to use this no-doubt lovely-and-useful thing.
    What do you think of a "hello world" dealie in examples/tests/something/something ?

    1. So, I could do an example, but it would be contrived. The idea is: you want to set up an ssh tunnel before running your tests (we do a lot of it). Does a contrived example, where the executable is "touch /tmp/foo", make any sense to do?

    2. I'd settle for contrived. "touch /tmp/foo" sounds lovely

  2. not sure if grawlix or valid perl

    1. not "$# is no longer supported at - line 1". Apparently, $^ is "The name of the current top-of-page format for the currently selected output channel"

  3. 
      
DT
LA
  1. Thank for the example. Looks imitate-able to me.

    Now to start the betting pool on how long before someone asks if they can use this as a http://facebook.github.io/buck/rule/genrule.html

    1. Yeah, that would be a pretty bad idea, because it means that Pants would the ability to really understand the dependencies. So let's hope nobody decides to do that.

  2. ...by the prep_command in the BUILD file

  3. 
      
DT
PE
  1. 
      
  2. edge case: a second run on a shared host will fail for permission error, maybe a ci host.

    mabye we need clean up hook too? :)

  3. i see, the clean up section is in the code, seems reasonable to have that part of BUILD as well, can be a TODO

  4. 
      
DT
  1. 
      
  2. For a real test, this would be totally unacceptable. For an example, I think it's fine.

  3. 
      
PA
  1. lgtm minus issues

  2. You probably want to use Popen and capture stderr/out and do with it what you will. Perhaps wrap these calls up in a workunit and hook the pipes into the workunit/runtracker system.

  3. src/python/pants/base/build_graph.py (Diff revision 3)
     
     

    Wasn't this already in another CR? Was that one rescinded or has it not upstreamed yet?

  4. 
      
LA
  1. 
      
  2. Hmm, Peiyu's not a dummy... which suggests that this could use a comment. Maybe something like...

    Prepare for the 'greet' test. Realistically, you wouldn't set

    up a prep_command just to create

    an emtpy temp file. This is meant

    as a simple example.

  3. 
      
DT
  1. 
      
  2. src/python/pants/base/build_graph.py (Diff revision 3)
     
     

    I just forgot to do --parent on the latest rbt; I always forget that it forgets about --parent. Will rebase.

  3. 
      
DT
PA
  1. 
      
  2. except OSError as e:

  3. 
      
DT
IT
  1. lgtm!

  2. 
      
DT
Review request changed

Status: Closed (submitted)

Loading...