1Test::DiagINC(3) User Contributed Perl Documentation Test::DiagINC(3)
2
3
4
6 Test::DiagINC - List modules and versions loaded if tests fail
7
9 version 0.008
10
12 # preferably load before anything else
13 use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC';
14 use Test::More;
15
17 Assuming you shipped your module to CPAN with working tests, test
18 failures from CPAN Testers <http://www.cpantesters.org/> might be due
19 to platform issues, Perl version issues or problems with dependencies.
20 This module helps you diagnose deep dependency problems by showing you
21 exactly what modules and versions were loaded during a test run.
22
23 When this module is loaded, it sets up an "END" block that will take
24 action if the program is about to exit with a non-zero exit code or if
25 $test_builder->is_passing is false by the time the "END" block is
26 reached. If that happens, this module prints out the names and version
27 numbers of non-local modules appearing in %INC at the end of the test.
28
29 For example:
30
31 $ perl -MTest::DiagINC -MTest::More -e 'fail("meh"); done_testing'
32 not ok 1 - meh
33 # Failed test 'meh'
34 # at -e line 1.
35 1..1
36 # Looks like you failed 1 test of 1.
37 # Listing modules and versions from %INC
38 # 5.018002 Config
39 # 5.68 Exporter
40 # 5.68 Exporter::Heavy
41 # 1.07 PerlIO
42 # 0.98 Test::Builder
43 # 0.98 Test::Builder::Module
44 # 0.003 Test::DiagINC
45 # 0.98 Test::More
46 # 1.22 overload
47 # 0.02 overloading
48 # 1.07 strict
49 # 1.03 vars
50 # 1.18 warnings
51 # 1.02 warnings::register
52
53 This module deliberately does not load any other modules during
54 runtime, instead delaying all loads until it needs to generate a
55 failure report in its "END" block. The only exception is loading strict
56 and warnings for self-check if and only if "RELEASE_TESTING" is true.
57 Therefore an empty invocation will look like this:
58
59 $ perl -MTest::DiagINC -e 'exit(1)'
60 # Listing modules from %INC
61 # 0.003 Test::DiagINC
62
63 NOTE: Because this module uses an "END" block, it is a good idea to
64 load it as early as possible, so the "END" block it installs will
65 execute as late as possible (see perlmod for details on how this
66 works). While this module does employ some cleverness to work around
67 load order, it is still a heuristic and is no substitute to loading
68 this module early. A notable side-effect is when a module is loaded in
69 an "END" block executing after the one installed by this library: such
70 modules will be "invisible" to us and will not be reported as part of
71 the diagnostic report.
72
73 Modules that appear to be sourced from below the current directory when
74 "Test::DiagINC" was loaded will be excluded from the report (e.g.
75 excludes local modules from "./", "lib/", "t/lib", and so on).
76
77 The heuristic of searching %INC for loaded modules may fail if the
78 module path loaded does not map to a package within the module file.
79
80 If "Test::More" is loaded, the output will go via the "diag" function.
81 Otherwise, it will just be sent to STDERR.
82
84 Bugs / Feature Requests
85 Please report any bugs or feature requests through the issue tracker at
86 <https://github.com/dagolden/Test-DiagINC/issues>. You will be
87 notified automatically of any progress on your issue.
88
89 Source Code
90 This is open source software. The code repository is available for
91 public review and contribution under the terms of the license.
92
93 <https://github.com/dagolden/Test-DiagINC>
94
95 git clone https://github.com/dagolden/Test-DiagINC.git
96
98 David Golden <dagolden@cpan.org>
99
101 • Peter Rabbitson <ribasushi@cpan.org>
102
103 • Roy Ivy III <rivy.dev@gmail.com>
104
106 This software is Copyright (c) 2014 by David Golden.
107
108 This is free software, licensed under:
109
110 The Apache License, Version 2.0, January 2004
111
112
113
114perl v5.32.1 2021-02-02 Test::DiagINC(3)