4 messages in com.perforce.jamming[jamming] how to make jam run a built...| From | Sent On | Attachments |
|---|---|---|
| Arnt Gulbrandsen | 27 Oct 2002 08:03 | |
| Oliver Schoenborn | 27 Oct 2002 11:25 | |
| Diane Holt | 27 Oct 2002 14:11 | |
| Oliver Schoenborn | 02 Nov 2002 18:12 |
| Subject: | [jamming] how to make jam run a built test program![]() |
|---|---|
| From: | Diane Holt (hol...@yahoo.com) |
| Date: | 10/27/2002 02:11:07 PM |
| List: | com.perforce.jamming |
--- Oliver Schoenborn <oliv...@utoronto.ca> wrote:
Hello, I'm trying to create a test action that will run a bunch of test programs built by jam.
If you always want all the tests to run whenever you ask for them, then you need to specify that with "Always". If you want them to only run when either whatever they're testing is newer than their output or they are themselves newer, then you'd need to specify that association, and you wouldn't use "Always".
rule RunMany { # not sure yet what next three # lines are for NotFile dummy ; Depends dummy : $(<) ; DEPENDS $(<) : $(>) ;
The NotFile line specifies a "pseudo-target" (ie., a target that never actually exists as a file) called "dummy". The Depends line says the "dummy" pseudo-target depends on the target specified in a RunMany (in your example, "tests"). The DEPENDS (which is the same as Depends, just old-style casing) line says that the target of a RunMany depends on its "source". I suppose the idea was to have a generic rule for "running many anythings specified to the right of the first colon and collectively called that which is specified to the left of it". But the "dummy" is, frankly, a bit silly, since a) the comment says "run each test", which sort of undermines the whole "generic" thing, and b) you could just do "NotFile $(<) ;" instead of having "dummy" (or just not have a NotFile at all -- although it's probably better to, since it makes things a bit clearer).
# run each test local _i ; for _i in [ FGristFiles $(2) ] { Run $(_i) ; } }
actions Run { $(1) }
RunMany tests : testFoo1 testFoo2 testBar1 testBar2 ; When I type "jam tests", nothing happens.
Because the only things that "tests" depends on are the tests named as its "source", and they exist and are up-to-date with respect to "tests", which is itself missing, but doesn't have any updating actions associated with it, since you're passing the test to Run, not "tests" (so it's regarded as a NotFile anyway, so Jam shines it on).
Also, where you're gristing will make it so that in order to run something individually, from anywhere other than TOP, you'd need to include the grist as part of the thing's name, which is pretty gruesome.
To have a generic run-many-anythings rule, do:
rule runMany { NotFile $(<) ; # not required, but probably clearer for thing in $(>) { Depends $(<) : $(thing) ; local t = [ FGristFiles $(thing) ] ; if $(t) = $(thing) { t = $(t:G=<.>) ; } Depends $(thing) : $(t) ; SEARCH on $(t) = $(SEARCH_SOURCE) ; Always $(t) ; runOne $(t) ; } }
actions runOne { $(<) }
And in your Jamfile, do:
runMany tests : test1 test2 ; runMany scripts : script1 script2 ; runMany doodahs : doodah1 ;
To run all the tests, do 'jam tests'. To run a single test, 'jam test1'. Ditto for any runMany target.
If you wanted just a dedicated run-tests rule, it'd be essentially the same, except you'd hard-code the pseudo-target name in the rule and not include it in the Jamfile target, and $(<) references would be referring to the tests (ie., there wouldn't be any $(>)'s):
rule runTests { for test in $(<) { Depends tests : $(test) ; local t = [ FGristFiles $(test) ] ; if $(t) = $(test) { t = $(t:G=<.>) ; } Depends $(test) : $(t) ; SEARCH on $(t) = $(SEARCH_SOURCE) ; Always $(t) ; runTest $(t) ; } }
actions runTest { $(<) }
And in your Jamfile:
runTests test1 test2 ;
Since "tests" doesn't appear in the Jamfile itself, though, you'd need to know that was the pseudo-target's name (of course that's true for most pseudo-targets [eg., lib, exe, etc.]).
Diane
===== (hol...@yahoo.com)
__________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/




