in reply to Re: Re: Re: Re: Re: Re: Makefile.PL even weirder on Windows
in thread Makefile.PL even weirder on Windows

I've just had a quick look at your test.t from Exporter-VA-1.2.3. Annoying comments/suggestions follow. Feel free to ignore :-)

I would strongly consider using Test::More and Test::Builder. It handles all the book keeping on test headers, footers and exit values for you. Implementing verbose and vv with Test::Builder is trivial.

You don't need the "#" after the "ok" and "not out" outputs. Currently the "#" character is used to indicate special kinds of test failure/success ("# skip" & "# TODO" tests). While Test::Harness copes happily with the "#" in other circumstances I would avoid it unless you are dealing with one of these special cases - just for the sake of clarity.

Consider testing the environment variable TEST_VERBOSE as well as your -verbose flag. That way you can do make test TEST_VERBOSE=1 to get your debug code.

The case when the code passed to verify dies should cause a failed test, rather than a printed error message. Conceptually the test (does this code produce this result) has failed.

Matter of personal style, but I would do:

{ package C1; use M1 v1.0 qw/--verbose_import &foo bar baz quux bazola + $ztesch --dump/ } verify "C1::foo (5)", "Called M1::foo (5)."; ...

instead of

package C1; use M1 v1.0 qw/--verbose_import &foo bar baz quux bazola $ztesch --dum +p/; sub verify; *verify= \&main::verify; verify "C1::foo (5)", "Called M1::foo (5)."; ...

to save having to alias verify into each module.

Replies are listed 'Best First'.
Re: Re^7: Makefile.PL even weirder on Windows
by John M. Dlugosz (Monsignor) on Jan 15, 2003 at 04:05 UTC
    Thanks for your comments.

    The case when the code passed to verify dies should cause a failed test, rather than a printed error message.

    Ah, good catch.

    You don't need the "#" after the "ok" and "not out" outputs

    I guess I misunderstood the directions, then. I thought it was for a comment after the formal part. So it just ignores everything after the /(not )?ok( \d+)/ and I can put my commentary right there, or after some other separator like a dash?

    I would strongly consider using Test::More

    After reading the articles on testing, I went to the docs on Test::More and it said

    STOP! If you're just getting started writing tests, have a look at Test::Simple first. This is a drop in replacement for Test::Simple which you can switch to once you get the hang of basic testing.
    I suppose I made it to that point, now?

    Consider testing the environment variable TEST_VERBOSE

    Good idea. I suppose that's what most people do, so they can just use n?make test and not have to run the script in another manner.

    ...to save having to alias verify into each module.

    Ah! Since I need to qualify everything anyway (since it's eval'ed elsewhere), there is no point to having the code lexically in the scope of that module! I missed that, thanks to the organic nature of "growing" rather than planning the script.

    —John

      So it just ignores everything after the /(not )?ok( \d+)/ and I can put my commentary right there, or after some other separator like a dash?

      Yup. from Test::Harness docs:

      test names Anything after the test number but before the # is considered to be the name of the test. ok 42 this is the name of the test Currently, Test::Harness does nothing with this infor- mation.
      I suppose I made it to that point, now?

      Yup. Your ready for Test::More :-)

      Here's a quick re-write of your test script in the Test::More idiom.

      Hopefully this comes across as simpler than the original :-)