1Test::Trap::Builder::SyUssteermSCaofnet(r3i)buted Perl DToecsutm:e:nTtraatpi:o:nBuilder::SystemSafe(3)
2
3
4
6 Test::Trap::Builder::SystemSafe - "Safe" capture strategies using
7 File::Temp
8
10 Version 0.3.4
11
13 This module provides capture strategies systemsafe, based on
14 File::Temp, for the trap's output layers. These strategies insists on
15 reopening the output file handles with the same descriptors, and
16 therefore, unlike Test::Trap::Builder::TempFile and
17 Test::Trap::Builder::PerlIO, is able to trap output from forked-off
18 processes, including system().
19
20 The import accepts a name (as a string; default systemsafe) and options
21 (as a hashref; by default empty), and registers a capture strategy with
22 that name and a variant implementation based on the options.
23
24 Note that you may specify different strategies for each output layer on
25 the trap.
26
27 See also Test::Trap (:stdout and :stderr) and Test::Trap::Builder
28 (output_layer).
29
31 The following options are recognized:
32
33 preserve_io_layers
34 A boolean, indicating whether to apply to the handles writing to and
35 reading from the tempfile, the same perlio layers as are found on the
36 to-be-trapped output handle.
37
38 io_layers
39 A colon-separated string representing perlio layers to be applied to
40 the handles writing to and reading from the tempfile.
41
42 If the preserve_io_layers option is set, these perlio layers will be
43 applied on top of the original (preserved) perlio layers.
44
46 Using File::Temp, we need privileges to create tempfiles.
47
48 We need disk space for the output of every trap (it should clean up
49 after the trap is sprung).
50
51 Disk access may be slow -- certainly compared to the in-memory files of
52 PerlIO.
53
54 If the file handle we try to trap using this strategy is on an in-
55 memory file, it would not be available to other processes in any case.
56 Rather than change the semantics of the trapped code or silently fail
57 to trap output from forked-off processes, we just raise an exception in
58 this case.
59
60 If there is another file handle with the same descriptor (f ex after an
61 "open OTHER, '>&=', THIS"), we can't get that file descriptor. Rather
62 than silently fail, we again raise an exception.
63
64 If the options specify (explicitly or via preserve on handles with)
65 perlio custom layers, they may (or may not) fail to apply to the
66 tempfile read and write handles.
67
68 Threads? No idea. It might even work correctly.
69
71 Please report any bugs or feature requests directly to the author.
72
74 Eirik Berg Hanssen, "<ebhanssen@cpan.org>"
75
77 Copyright 2006-2014 Eirik Berg Hanssen, All Rights Reserved.
78
79 This program is free software; you can redistribute it and/or modify it
80 under the same terms as Perl itself.
81
82
83
84perl v5.32.1 2021-01-27Test::Trap::Builder::SystemSafe(3)