run-tests

From: Date: Sun, 09 Apr 2006 17:10:48 +0000
Subject: run-tests
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-42175@lists.php.net to get a copy of this message
Bonjour, Do you know run-tests ? These are basic means to run "unit" tests. To basically valid a release. It's known we accept several formats. * php "roots" run-tests.php as does DB * pear run-tests as do lot of packages * phpunit and phpunit2 (there's a format to get them basically run by pear run-tests) * phpsimple or other external means The formers accept some .phpt to run. It is simply separed in sections, as --SECTION-- : $ cat phpt.phpt --TEST-- Test name --FILE-- <?php echo 'test'; ?> --EXPECT-- test $ pear run-tests phpt.phpt Running 1 tests PASS Test name[phpt.phpt] TOTAL TIME: 00:00 1 PASSED TESTS 0 SKIPPED TESTS You can use --ARGS-- sections as --TEST-- Test arg --ARGS-- testArg --FILE-- <?php echo $_SERVER['argv'][1]; ?> --EXPECT-- testArg That does not work , "testArg" is in $_SERVER['argv'][2] The $_SERVER['argv'][1] is forced to "--" as made in PEAR/RunTest.php ... or is it a compat thing ? However, I wanted some direct input, it seems to work: --TEST-- Test for input --ARGS-- 2>&1 <<EOT line 1 line 2 EOT --FILE-- <?php $stdin = fopen('php://stdin', 'r'); $input = fread($stdin, 4096); echo $input; error_log('end of test'); ?> --EXPECT-- line 1 line 2 end of test the "--" is sure in args the extra 2>&1 from PEAR/RunTest.php is swallowed. so it's needed again to put it forth to get the error_log() thing. You like tests ? Regards -- toggg

« previous php.pear.dev (#42175) next »