%% [EMAIL PROTECTED] (Bj�rn Lindstr�m) writes:

  bl> %.class: %.java
  bl>   $(JAVAC) $<

  bl> test: $(TESTCLASSES)
  bl> $(TESTCLASSES): Test%: %
  bl>   $(JUNIT) $(patsubst %.class,%,$@)

  bl> Now, if I run 'make test', make will start out building
  bl> BetterTray.class, like it should, and then go on to run $(JUNIT)
  bl> on TestBetterTray.class. So, what's missing is that it doesn't
  bl> actually build TestBetterTray.class in between those steps. How
  bl> would I make the

  bl> $(TESTCLASSES): Test%: %

  bl> rule also depend on the build rule for the corresponding test
  bl> class?  (The %.class: %.java rule.)

You can't do it that way: a given target can only have one command
script to build it (unless you use double-colons but that's a while
different story).

You'll need to either add the JAVAC line to the same script as the JUNIT
line, like:

 $(TESTCLASSES): Test%: %
        $(JAVAC) $<
        $(JUNIT) $(patsubst %.class,%,$@)

The disadvantage here is if the unit test fails, the class is still
created so it won't be run again.  You could, of course, write shell
commands to delete the file for you when the unit test fails.

Or you could put the unit test into another rule, something like:

    RUNTESTCLASSES = $(TESTCLASSES:%=run.%)
    test: $(RUNTESTCLASSES)

    $(RUNTESTCLASSES): run.% : %
            $(JUNIT) $(patsubst %.class,%,$<)
            @touch $@

or whatever.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to