SYNOPSIS
To verify that B::Concise properly reports whether functions are XS or perl, we test against 2 (currently) core packages which have lots of XS functions: B and Digest::MD5. They're listed in %$testpkgs, along with a list of functions that are (or are not) XS. For brevity, you can specify the shorter list; if they're non-xs routines, start list with a '!'. Data::Dumper is also tested, partly to prove the non-! usage.
We demand-load each package, scan its stash for function names, and mark them as XS/not-XS according to the list given for each package. Then we test B::Concise's report on each.
OPTIONS AND ARGUMENTS
-v
and -V
trigger 2 levels of verbosity.
-a
uses Module::CoreList to run all core packages through the test, which gives some interesting results.
-c
causes the expected XS/non-XS results to be marked with corrections, which are then reported at program END, in a Data::Dumper statement
-r <file>
reads a file, as written by -c
, and adjusts the expected results accordingly. The file is 'required', so @INC settings apply.
If module-names are given as args, those packages are run through the test harness; this is handy for collecting further items to test, and may be useful otherwise (ie just to see).
EXAMPLES
All following examples avoid using PERL_CORE=1, since that changes @INC
- ./perl -Ilib -wS ext/B/t/concise-xs.t -c Storable
-
Tests Storable.pm for XS/non-XS routines, writes findings (along with test results) to stdout. You could edit results to produce a test file, as in next example
- ./perl -Ilib -wS ext/B/t/concise-xs.t -r ./storable
-
Loads file, and uses it to set expectations, and run tests
- ./perl -Ilib -wS ext/B/t/concise-xs.t -avc > ../foo-avc 2> ../foo-avc2
-
Gets module list from Module::Corelist, and runs them all through the test. Since -c is used, this generates corrections, which are saved in a file, which is edited down to produce ../all-xs
- ./perl -Ilib -wS ext/B/t/concise-xs.t -cr ../all-xs > ../foo 2> ../foo2
-
This runs the tests specified in the file created in previous example. -c is used again, and stdout verifies that all the expected results given by -r ../all-xs are now seen.
Looking at ../foo2, you'll see 34 occurrences of the following error:
# err: Can't use an undefined value as a SCALAR reference at # lib/B/Concise.pm line 634, <DATA> line 1.