How can I run Perl test suite automatically when files change?

后端 未结 7 654
余生分开走
余生分开走 2021-01-06 05:50

Is there a tool that would watch file changes in a directory tree of a Perl application and re-run the test suite every time I save changes to some module? Something akin to

7条回答
  •  清歌不尽
    2021-01-06 05:59

    I don't know of any generic filesystem monitoring widget, but here's the Perl specific half.

    sub run_tests {
        my $prove_out = `prove -lr`;
        my $tests_passed = $? == 0;
    
        return "" if $tests_passed;
        return $prove_out;
    }
    

    This uses the prove utility that comes with Test::Harness 3. It exits non-zero on test failure. Plug that into your filesystem monitoring thing and you're set.

提交回复
热议问题