exiftool-vendored.exe 12.82.0 → 12.82.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +6 -0
  2. package/bin/exiftool.exe +0 -0
  3. package/bin/exiftool_files/Licenses_Strawberry_Perl.zip +0 -0
  4. package/bin/exiftool_files/lib/Archive/Zip/Archive.pm +399 -65
  5. package/bin/exiftool_files/lib/Archive/Zip/DirectoryMember.pm +1 -1
  6. package/bin/exiftool_files/lib/Archive/Zip/FileMember.pm +1 -1
  7. package/bin/exiftool_files/lib/Archive/Zip/Member.pm +499 -195
  8. package/bin/exiftool_files/lib/Archive/Zip/NewFileMember.pm +1 -1
  9. package/bin/exiftool_files/lib/Archive/Zip/StringMember.pm +2 -2
  10. package/bin/exiftool_files/lib/Archive/Zip/ZipFileMember.pm +79 -20
  11. package/bin/exiftool_files/lib/Archive/Zip.pm +179 -29
  12. package/bin/exiftool_files/lib/AutoLoader.pm +453 -0
  13. package/bin/exiftool_files/lib/B/Deparse.pm +209 -137
  14. package/bin/exiftool_files/lib/B.pm +1 -1
  15. package/bin/exiftool_files/lib/Benchmark.pm +1123 -0
  16. package/bin/exiftool_files/lib/Class/Struct.pm +2 -2
  17. package/bin/exiftool_files/lib/Compress/Raw/Bzip2.pm +14 -9
  18. package/bin/exiftool_files/lib/Compress/Raw/Lzma.pm +982 -0
  19. package/bin/exiftool_files/lib/Compress/Raw/Zlib.pm +91 -86
  20. package/bin/exiftool_files/lib/Compress/Zlib.pm +105 -100
  21. package/bin/exiftool_files/lib/Config.pm +9 -9
  22. package/bin/exiftool_files/lib/Config_heavy.pl +36 -33
  23. package/bin/exiftool_files/lib/CryptX.pm +2 -82
  24. package/bin/exiftool_files/lib/Data/Dumper.pm +2 -2
  25. package/bin/exiftool_files/lib/Digest/MD5.pm +12 -9
  26. package/bin/exiftool_files/lib/Digest/Perl/MD5.pm +1 -191
  27. package/bin/exiftool_files/lib/Digest/base.pm +26 -20
  28. package/bin/exiftool_files/lib/DynaLoader.pm +7 -4
  29. package/bin/exiftool_files/lib/Encode.pm +3 -3
  30. package/bin/exiftool_files/lib/Errno.pm +13 -13
  31. package/bin/exiftool_files/lib/Exporter/Heavy.pm +2 -2
  32. package/bin/exiftool_files/lib/Exporter.pm +1 -1
  33. package/bin/exiftool_files/lib/ExtUtils/Command/MM.pm +323 -0
  34. package/bin/exiftool_files/lib/ExtUtils/Command.pm +382 -0
  35. package/bin/exiftool_files/lib/File/Find.pm +1 -1
  36. package/bin/exiftool_files/lib/File/Glob.pm +1 -8
  37. package/bin/exiftool_files/lib/File/GlobMapper.pm +2 -2
  38. package/bin/exiftool_files/lib/File/HomeDir/Darwin/Carbon.pm +2 -40
  39. package/bin/exiftool_files/lib/File/HomeDir/Darwin/Cocoa.pm +2 -34
  40. package/bin/exiftool_files/lib/File/HomeDir/Darwin.pm +2 -28
  41. package/bin/exiftool_files/lib/File/HomeDir/Driver.pm +2 -35
  42. package/bin/exiftool_files/lib/File/HomeDir/FreeDesktop.pm +2 -62
  43. package/bin/exiftool_files/lib/File/HomeDir/MacOS9.pm +2 -53
  44. package/bin/exiftool_files/lib/File/HomeDir/Test.pm +2 -43
  45. package/bin/exiftool_files/lib/File/HomeDir/Unix.pm +2 -53
  46. package/bin/exiftool_files/lib/File/HomeDir/Windows.pm +2 -69
  47. package/bin/exiftool_files/lib/File/HomeDir.pm +5 -416
  48. package/bin/exiftool_files/lib/File/Path.pm +3 -3
  49. package/bin/exiftool_files/lib/File/Spec/Win32.pm +2 -2
  50. package/bin/exiftool_files/lib/File/Temp.pm +70 -35
  51. package/bin/exiftool_files/lib/File/Which.pm +1 -240
  52. package/bin/exiftool_files/lib/File/stat.pm +3 -2
  53. package/bin/exiftool_files/lib/IO/Compress/Adapter/Bzip2.pm +16 -17
  54. package/bin/exiftool_files/lib/IO/Compress/Adapter/Deflate.pm +19 -20
  55. package/bin/exiftool_files/lib/IO/Compress/Base/Common.pm +5 -5
  56. package/bin/exiftool_files/lib/IO/Compress/Base.pm +35 -26
  57. package/bin/exiftool_files/lib/IO/Compress/Brotli.pm +159 -0
  58. package/bin/exiftool_files/lib/IO/Compress/Bzip2.pm +50 -25
  59. package/bin/exiftool_files/lib/IO/Compress/Gzip/Constants.pm +6 -6
  60. package/bin/exiftool_files/lib/IO/Compress/Gzip.pm +58 -32
  61. package/bin/exiftool_files/lib/IO/Compress/RawDeflate.pm +63 -38
  62. package/bin/exiftool_files/lib/IO/Compress/Zlib/Extra.pm +20 -20
  63. package/bin/exiftool_files/lib/IO/Dir.pm +1 -1
  64. package/bin/exiftool_files/lib/IO/File.pm +1 -1
  65. package/bin/exiftool_files/lib/IO/Handle.pm +1 -21
  66. package/bin/exiftool_files/lib/IO/Pipe.pm +1 -1
  67. package/bin/exiftool_files/lib/IO/Seekable.pm +1 -1
  68. package/bin/exiftool_files/lib/IO/Select.pm +16 -2
  69. package/bin/exiftool_files/lib/IO/Socket/INET.pm +14 -9
  70. package/bin/exiftool_files/lib/IO/Socket/UNIX.pm +17 -1
  71. package/bin/exiftool_files/lib/IO/Socket.pm +474 -126
  72. package/bin/exiftool_files/lib/IO/String.pm +425 -0
  73. package/bin/exiftool_files/lib/IO/Uncompress/Adapter/Inflate.pm +13 -14
  74. package/bin/exiftool_files/lib/IO/Uncompress/Base.pm +142 -132
  75. package/bin/exiftool_files/lib/IO/Uncompress/Brotli.pm +119 -0
  76. package/bin/exiftool_files/lib/IO/Uncompress/Gunzip.pm +43 -37
  77. package/bin/exiftool_files/lib/IO/Uncompress/RawInflate.pm +49 -43
  78. package/bin/exiftool_files/lib/IO.pm +2 -2
  79. package/bin/exiftool_files/lib/List/Util.pm +97 -8
  80. package/bin/exiftool_files/lib/MIME/Base64.pm +5 -5
  81. package/bin/exiftool_files/lib/MIME/Charset/_Compat.pm +106 -0
  82. package/bin/exiftool_files/lib/MIME/Charset.pm +1303 -0
  83. package/bin/exiftool_files/lib/Math/BigFloat.pm +444 -27
  84. package/bin/exiftool_files/lib/Math/BigInt/Calc.pm +296 -313
  85. package/bin/exiftool_files/lib/Math/BigInt/FastCalc.pm +1 -1
  86. package/bin/exiftool_files/lib/Math/BigInt/GMP.pm +2 -115
  87. package/bin/exiftool_files/lib/Math/BigInt/LTM.pm +2 -24
  88. package/bin/exiftool_files/lib/Math/BigInt/Lib.pm +61 -32
  89. package/bin/exiftool_files/lib/Math/BigInt.pm +292 -107
  90. package/bin/exiftool_files/lib/POSIX.pm +1 -1
  91. package/bin/exiftool_files/lib/PerlIO/scalar.pm +41 -0
  92. package/bin/exiftool_files/lib/PerlIO.pm +397 -0
  93. package/bin/exiftool_files/lib/Portable/CPAN.pm +94 -94
  94. package/bin/exiftool_files/lib/Portable/Config.pm +94 -94
  95. package/bin/exiftool_files/lib/Portable/FileSpec.pm +180 -180
  96. package/bin/exiftool_files/lib/Portable/HomeDir.pm +110 -110
  97. package/bin/exiftool_files/lib/Portable/LoadYaml.pm +430 -430
  98. package/bin/exiftool_files/lib/Portable/minicpan.pm +55 -55
  99. package/bin/exiftool_files/lib/Portable.pm +246 -320
  100. package/bin/exiftool_files/lib/Scalar/Util.pm +9 -4
  101. package/bin/exiftool_files/lib/Socket.pm +16 -12
  102. package/bin/exiftool_files/lib/Storable.pm +1444 -1441
  103. package/bin/exiftool_files/lib/TAP/Base.pm +133 -0
  104. package/bin/exiftool_files/lib/TAP/Formatter/Base.pm +467 -0
  105. package/bin/exiftool_files/lib/TAP/Formatter/Color.pm +116 -0
  106. package/bin/exiftool_files/lib/TAP/Formatter/Console/ParallelSession.pm +201 -0
  107. package/bin/exiftool_files/lib/TAP/Formatter/Console/Session.pm +205 -0
  108. package/bin/exiftool_files/lib/TAP/Formatter/Console.pm +100 -0
  109. package/bin/exiftool_files/lib/TAP/Formatter/File/Session.pm +95 -0
  110. package/bin/exiftool_files/lib/TAP/Formatter/File.pm +56 -0
  111. package/bin/exiftool_files/lib/TAP/Formatter/Session.pm +220 -0
  112. package/bin/exiftool_files/lib/TAP/Harness/Beyond.pod +426 -0
  113. package/bin/exiftool_files/lib/TAP/Harness/Env.pm +215 -0
  114. package/bin/exiftool_files/lib/TAP/Harness.pm +1054 -0
  115. package/bin/exiftool_files/lib/TAP/Object.pm +155 -0
  116. package/bin/exiftool_files/lib/TAP/Parser/Aggregator.pm +414 -0
  117. package/bin/exiftool_files/lib/TAP/Parser/Grammar.pm +584 -0
  118. package/bin/exiftool_files/lib/TAP/Parser/Iterator/Array.pm +100 -0
  119. package/bin/exiftool_files/lib/TAP/Parser/Iterator/Process.pm +378 -0
  120. package/bin/exiftool_files/lib/TAP/Parser/Iterator/Stream.pm +116 -0
  121. package/bin/exiftool_files/lib/TAP/Parser/Iterator.pm +162 -0
  122. package/bin/exiftool_files/lib/TAP/Parser/IteratorFactory.pm +339 -0
  123. package/bin/exiftool_files/lib/TAP/Parser/Multiplexer.pm +194 -0
  124. package/bin/exiftool_files/lib/TAP/Parser/Result/Bailout.pm +62 -0
  125. package/bin/exiftool_files/lib/TAP/Parser/Result/Comment.pm +60 -0
  126. package/bin/exiftool_files/lib/TAP/Parser/Result/Plan.pm +119 -0
  127. package/bin/exiftool_files/lib/TAP/Parser/Result/Pragma.pm +62 -0
  128. package/bin/exiftool_files/lib/TAP/Parser/Result/Test.pm +271 -0
  129. package/bin/exiftool_files/lib/TAP/Parser/Result/Unknown.pm +48 -0
  130. package/bin/exiftool_files/lib/TAP/Parser/Result/Version.pm +62 -0
  131. package/bin/exiftool_files/lib/TAP/Parser/Result/YAML.pm +61 -0
  132. package/bin/exiftool_files/lib/TAP/Parser/Result.pm +297 -0
  133. package/bin/exiftool_files/lib/TAP/Parser/ResultFactory.pm +183 -0
  134. package/bin/exiftool_files/lib/TAP/Parser/Scheduler/Job.pm +127 -0
  135. package/bin/exiftool_files/lib/TAP/Parser/Scheduler/Spinner.pm +61 -0
  136. package/bin/exiftool_files/lib/TAP/Parser/Scheduler.pm +448 -0
  137. package/bin/exiftool_files/lib/TAP/Parser/Source.pm +381 -0
  138. package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/Executable.pm +184 -0
  139. package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/File.pm +136 -0
  140. package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/Handle.pm +124 -0
  141. package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/Perl.pm +370 -0
  142. package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/RawTAP.pm +130 -0
  143. package/bin/exiftool_files/lib/TAP/Parser/SourceHandler.pm +191 -0
  144. package/bin/exiftool_files/lib/TAP/Parser/YAMLish/Reader.pm +332 -0
  145. package/bin/exiftool_files/lib/TAP/Parser/YAMLish/Writer.pm +254 -0
  146. package/bin/exiftool_files/lib/TAP/Parser.pm +1931 -0
  147. package/bin/exiftool_files/lib/Test/Builder/Formatter.pm +107 -0
  148. package/bin/exiftool_files/lib/Test/Builder/IO/Scalar.pm +659 -0
  149. package/bin/exiftool_files/lib/Test/Builder/Module.pm +182 -0
  150. package/bin/exiftool_files/lib/Test/Builder/Tester/Color.pm +51 -0
  151. package/bin/exiftool_files/lib/Test/Builder/Tester.pm +675 -0
  152. package/bin/exiftool_files/lib/Test/Builder/TodoDiag.pm +68 -0
  153. package/bin/exiftool_files/lib/Test/Builder.pm +2653 -0
  154. package/bin/exiftool_files/lib/Test/Harness.pm +618 -0
  155. package/bin/exiftool_files/lib/Test/More.pm +1997 -0
  156. package/bin/exiftool_files/lib/Test/Simple.pm +220 -0
  157. package/bin/exiftool_files/lib/Test/Tester/Capture.pm +241 -0
  158. package/bin/exiftool_files/lib/Test/Tester/CaptureRunner.pm +79 -0
  159. package/bin/exiftool_files/lib/Test/Tester/Delegate.pm +45 -0
  160. package/bin/exiftool_files/lib/Test/Tester.pm +695 -0
  161. package/bin/exiftool_files/lib/Test/Tutorial.pod +618 -0
  162. package/bin/exiftool_files/lib/Test/use/ok.pm +64 -0
  163. package/bin/exiftool_files/lib/Text/ParseWords.pm +303 -0
  164. package/bin/exiftool_files/lib/Tie/StdHandle.pm +2 -2
  165. package/bin/exiftool_files/lib/Time/HiRes.pm +73 -68
  166. package/bin/exiftool_files/lib/Time/Local.pm +82 -35
  167. package/bin/exiftool_files/lib/Time/Piece.pm +19 -4
  168. package/bin/exiftool_files/lib/Time/Seconds.pm +1 -1
  169. package/bin/exiftool_files/lib/UNIVERSAL.pm +203 -0
  170. package/bin/exiftool_files/lib/Unicode/GCString.pm +60 -0
  171. package/bin/exiftool_files/lib/Unicode/LineBreak/Constants.pm +68 -0
  172. package/bin/exiftool_files/lib/Unicode/LineBreak.pm +248 -0
  173. package/bin/exiftool_files/lib/Win32/API/Struct.pm +1 -177
  174. package/bin/exiftool_files/lib/Win32/API/Type.pm +1 -100
  175. package/bin/exiftool_files/lib/Win32/API.pm +1 -830
  176. package/bin/exiftool_files/lib/Win32/FindFile.pm +2 -123
  177. package/bin/exiftool_files/lib/Win32.pm +213 -89
  178. package/bin/exiftool_files/lib/Win32API/File.pm +1 -1
  179. package/bin/exiftool_files/lib/auto/B/B.xs.dll +0 -0
  180. package/bin/exiftool_files/lib/auto/Compress/Raw/Bzip2/Bzip2.xs.dll +0 -0
  181. package/bin/exiftool_files/lib/auto/Compress/Raw/Lzma/Lzma.xs.dll +0 -0
  182. package/bin/exiftool_files/lib/auto/Compress/Raw/Lzma/autosplit.ix +3 -0
  183. package/bin/exiftool_files/lib/auto/Compress/Raw/Zlib/Zlib.xs.dll +0 -0
  184. package/bin/exiftool_files/lib/auto/CryptX/CryptX.xs.dll +0 -0
  185. package/bin/exiftool_files/lib/auto/Cwd/Cwd.xs.dll +0 -0
  186. package/bin/exiftool_files/lib/auto/Data/Dumper/Dumper.xs.dll +0 -0
  187. package/bin/exiftool_files/lib/auto/Digest/MD5/MD5.xs.dll +0 -0
  188. package/bin/exiftool_files/lib/auto/Digest/SHA/SHA.xs.dll +0 -0
  189. package/bin/exiftool_files/lib/auto/Encode/Encode.xs.dll +0 -0
  190. package/bin/exiftool_files/lib/auto/Fcntl/Fcntl.xs.dll +0 -0
  191. package/bin/exiftool_files/lib/auto/File/Glob/Glob.xs.dll +0 -0
  192. package/bin/exiftool_files/lib/auto/IO/Compress/Brotli/Brotli.xs.dll +0 -0
  193. package/bin/exiftool_files/lib/auto/IO/IO.xs.dll +0 -0
  194. package/bin/exiftool_files/lib/auto/List/Util/Util.xs.dll +0 -0
  195. package/bin/exiftool_files/lib/auto/MIME/Base64/Base64.xs.dll +0 -0
  196. package/bin/exiftool_files/lib/auto/Math/BigInt/FastCalc/FastCalc.xs.dll +0 -0
  197. package/bin/exiftool_files/lib/auto/Math/BigInt/GMP/GMP.xs.dll +0 -0
  198. package/bin/exiftool_files/lib/auto/POSIX/POSIX.xs.dll +0 -0
  199. package/bin/exiftool_files/lib/auto/PerlIO/scalar/scalar.xs.dll +0 -0
  200. package/bin/exiftool_files/lib/auto/Socket/Socket.xs.dll +0 -0
  201. package/bin/exiftool_files/lib/auto/Storable/Storable.xs.dll +0 -0
  202. package/bin/exiftool_files/lib/auto/Time/HiRes/HiRes.xs.dll +0 -0
  203. package/bin/exiftool_files/lib/auto/Time/Piece/Piece.xs.dll +0 -0
  204. package/bin/exiftool_files/lib/auto/Unicode/LineBreak/LineBreak.xs.dll +0 -0
  205. package/bin/exiftool_files/lib/auto/Win32/API/API.xs.dll +0 -0
  206. package/bin/exiftool_files/lib/auto/Win32/FindFile/FindFile.xs.dll +0 -0
  207. package/bin/exiftool_files/lib/auto/Win32/Win32.xs.dll +0 -0
  208. package/bin/exiftool_files/lib/auto/Win32API/File/File.xs.dll +0 -0
  209. package/bin/exiftool_files/lib/auto/mro/mro.xs.dll +0 -0
  210. package/bin/exiftool_files/lib/auto/re/re.xs.dll +0 -0
  211. package/bin/exiftool_files/lib/feature.pm +49 -17
  212. package/bin/exiftool_files/lib/mro.pm +4 -20
  213. package/bin/exiftool_files/lib/overload.pm +15 -15
  214. package/bin/exiftool_files/lib/parent.pm +10 -2
  215. package/bin/exiftool_files/lib/re.pm +91 -33
  216. package/bin/exiftool_files/lib/warnings.pm +17 -6
  217. package/bin/exiftool_files/libgcc_s_seh-1.dll +0 -0
  218. package/bin/exiftool_files/liblzma-5__.dll +0 -0
  219. package/bin/exiftool_files/libstdc++-6.dll +0 -0
  220. package/bin/exiftool_files/libwinpthread-1.dll +0 -0
  221. package/bin/exiftool_files/perl.exe +0 -0
  222. package/bin/exiftool_files/perl532.dll +0 -0
  223. package/package.json +5 -3
  224. package/bin/exiftool_files/libgcc_s_dw2-1.dll +0 -0
  225. package/bin/exiftool_files/perl530.dll +0 -0
@@ -0,0 +1,448 @@
1
+ package TAP::Parser::Scheduler;
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ use Carp;
7
+ use TAP::Parser::Scheduler::Job;
8
+ use TAP::Parser::Scheduler::Spinner;
9
+
10
+ =head1 NAME
11
+
12
+ TAP::Parser::Scheduler - Schedule tests during parallel testing
13
+
14
+ =head1 VERSION
15
+
16
+ Version 3.42
17
+
18
+ =cut
19
+
20
+ our $VERSION = '3.42';
21
+
22
+ =head1 SYNOPSIS
23
+
24
+ use TAP::Parser::Scheduler;
25
+
26
+ =head1 DESCRIPTION
27
+
28
+ =head1 METHODS
29
+
30
+ =head2 Class Methods
31
+
32
+ =head3 C<new>
33
+
34
+ my $sched = TAP::Parser::Scheduler->new(tests => \@tests);
35
+ my $sched = TAP::Parser::Scheduler->new(
36
+ tests => [ ['t/test_name.t','Test Description'], ... ],
37
+ rules => \%rules,
38
+ );
39
+
40
+ Given 'tests' and optional 'rules' as input, returns a new
41
+ C<TAP::Parser::Scheduler> object. Each member of C<@tests> should be either a
42
+ a test file name, or a two element arrayref, where the first element is a test
43
+ file name, and the second element is a test description. By default, we'll use
44
+ the test name as the description.
45
+
46
+ The optional C<rules> attribute provides direction on which tests should be run
47
+ in parallel and which should be run sequentially. If no rule data structure is
48
+ provided, a default data structure is used which makes every test eligible to
49
+ be run in parallel:
50
+
51
+ { par => '**' },
52
+
53
+ The rules data structure is documented more in the next section.
54
+
55
+ =head2 Rules data structure
56
+
57
+ The "C<rules>" data structure is the the heart of the scheduler. It allows you
58
+ to express simple rules like "run all tests in sequence" or "run all tests in
59
+ parallel except these five tests.". However, the rules structure also supports
60
+ glob-style pattern matching and recursive definitions, so you can also express
61
+ arbitarily complicated patterns.
62
+
63
+ The rule must only have one top level key: either 'par' for "parallel" or 'seq'
64
+ for "sequence".
65
+
66
+ Values must be either strings with possible glob-style matching, or arrayrefs
67
+ of strings or hashrefs which follow this pattern recursively.
68
+
69
+ Every element in an arrayref directly below a 'par' key is eligible to be run
70
+ in parallel, while vavalues directly below a 'seq' key must be run in sequence.
71
+
72
+ =head3 Rules examples
73
+
74
+ Here are some examples:
75
+
76
+ # All tests be run in parallel (the default rule)
77
+ { par => '**' },
78
+
79
+ # Run all tests in sequence, except those starting with "p"
80
+ { par => 't/p*.t' },
81
+
82
+ # Run all tests in parallel, except those starting with "p"
83
+ {
84
+ seq => [
85
+ { seq => 't/p*.t' },
86
+ { par => '**' },
87
+ ],
88
+ }
89
+
90
+ # Run some startup tests in sequence, then some parallel tests then some
91
+ # teardown tests in sequence.
92
+ {
93
+ seq => [
94
+ { seq => 't/startup/*.t' },
95
+ { par => ['t/a/*.t','t/b/*.t','t/c/*.t'], }
96
+ { seq => 't/shutdown/*.t' },
97
+ ],
98
+ },
99
+
100
+
101
+ =head3 Rules resolution
102
+
103
+ =over 4
104
+
105
+ =item * By default, all tests are eligible to be run in parallel. Specifying any of your own rules removes this one.
106
+
107
+ =item * "First match wins". The first rule that matches a test will be the one that applies.
108
+
109
+ =item * Any test which does not match a rule will be run in sequence at the end of the run.
110
+
111
+ =item * The existence of a rule does not imply selecting a test. You must still specify the tests to run.
112
+
113
+ =item * Specifying a rule to allow tests to run in parallel does not make the run in parallel. You still need specify the number of parallel C<jobs> in your Harness object.
114
+
115
+ =back
116
+
117
+ =head3 Glob-style pattern matching for rules
118
+
119
+ We implement our own glob-style pattern matching. Here are the patterns it supports:
120
+
121
+ ** is any number of characters, including /, within a pathname
122
+ * is zero or more characters within a filename/directory name
123
+ ? is exactly one character within a filename/directory name
124
+ {foo,bar,baz} is any of foo, bar or baz.
125
+ \ is an escape character
126
+
127
+ =cut
128
+
129
+ sub new {
130
+ my $class = shift;
131
+
132
+ croak "Need a number of key, value pairs" if @_ % 2;
133
+
134
+ my %args = @_;
135
+ my $tests = delete $args{tests} || croak "Need a 'tests' argument";
136
+ my $rules = delete $args{rules} || { par => '**' };
137
+
138
+ croak "Unknown arg(s): ", join ', ', sort keys %args
139
+ if keys %args;
140
+
141
+ # Turn any simple names into a name, description pair. TODO: Maybe
142
+ # construct jobs here?
143
+ my $self = bless {}, $class;
144
+
145
+ $self->_set_rules( $rules, $tests );
146
+
147
+ return $self;
148
+ }
149
+
150
+ # Build the scheduler data structure.
151
+ #
152
+ # SCHEDULER-DATA ::= JOB
153
+ # || ARRAY OF ARRAY OF SCHEDULER-DATA
154
+ #
155
+ # The nested arrays are the key to scheduling. The outer array contains
156
+ # a list of things that may be executed in parallel. Whenever an
157
+ # eligible job is sought any element of the outer array that is ready to
158
+ # execute can be selected. The inner arrays represent sequential
159
+ # execution. They can only proceed when the first job is ready to run.
160
+
161
+ sub _set_rules {
162
+ my ( $self, $rules, $tests ) = @_;
163
+
164
+ # Convert all incoming tests to job objects.
165
+ # If no test description is provided use the file name as the description.
166
+ my @tests = map { TAP::Parser::Scheduler::Job->new(@$_) }
167
+ map { 'ARRAY' eq ref $_ ? $_ : [ $_, $_ ] } @$tests;
168
+ my $schedule = $self->_rule_clause( $rules, \@tests );
169
+
170
+ # If any tests are left add them as a sequential block at the end of
171
+ # the run.
172
+ $schedule = [ [ $schedule, @tests ] ] if @tests;
173
+
174
+ $self->{schedule} = $schedule;
175
+ }
176
+
177
+ sub _rule_clause {
178
+ my ( $self, $rule, $tests ) = @_;
179
+ croak 'Rule clause must be a hash'
180
+ unless 'HASH' eq ref $rule;
181
+
182
+ my @type = keys %$rule;
183
+ croak 'Rule clause must have exactly one key'
184
+ unless @type == 1;
185
+
186
+ my %handlers = (
187
+ par => sub {
188
+ [ map { [$_] } @_ ];
189
+ },
190
+ seq => sub { [ [@_] ] },
191
+ );
192
+
193
+ my $handler = $handlers{ $type[0] }
194
+ || croak 'Unknown scheduler type: ', $type[0];
195
+ my $val = $rule->{ $type[0] };
196
+
197
+ return $handler->(
198
+ map {
199
+ 'HASH' eq ref $_
200
+ ? $self->_rule_clause( $_, $tests )
201
+ : $self->_expand( $_, $tests )
202
+ } 'ARRAY' eq ref $val ? @$val : $val
203
+ );
204
+ }
205
+
206
+ sub _glob_to_regexp {
207
+ my ( $self, $glob ) = @_;
208
+ my $nesting;
209
+ my $pattern;
210
+
211
+ while (1) {
212
+ if ( $glob =~ /\G\*\*/gc ) {
213
+
214
+ # ** is any number of characters, including /, within a pathname
215
+ $pattern .= '.*?';
216
+ }
217
+ elsif ( $glob =~ /\G\*/gc ) {
218
+
219
+ # * is zero or more characters within a filename/directory name
220
+ $pattern .= '[^/]*';
221
+ }
222
+ elsif ( $glob =~ /\G\?/gc ) {
223
+
224
+ # ? is exactly one character within a filename/directory name
225
+ $pattern .= '[^/]';
226
+ }
227
+ elsif ( $glob =~ /\G\{/gc ) {
228
+
229
+ # {foo,bar,baz} is any of foo, bar or baz.
230
+ $pattern .= '(?:';
231
+ ++$nesting;
232
+ }
233
+ elsif ( $nesting and $glob =~ /\G,/gc ) {
234
+
235
+ # , is only special inside {}
236
+ $pattern .= '|';
237
+ }
238
+ elsif ( $nesting and $glob =~ /\G\}/gc ) {
239
+
240
+ # } that matches { is special. But unbalanced } are not.
241
+ $pattern .= ')';
242
+ --$nesting;
243
+ }
244
+ elsif ( $glob =~ /\G(\\.)/gc ) {
245
+
246
+ # A quoted literal
247
+ $pattern .= $1;
248
+ }
249
+ elsif ( $glob =~ /\G([\},])/gc ) {
250
+
251
+ # Sometimes meta characters
252
+ $pattern .= '\\' . $1;
253
+ }
254
+ else {
255
+
256
+ # Eat everything that is not a meta character.
257
+ $glob =~ /\G([^{?*\\\},]*)/gc;
258
+ $pattern .= quotemeta $1;
259
+ }
260
+ return $pattern if pos $glob == length $glob;
261
+ }
262
+ }
263
+
264
+ sub _expand {
265
+ my ( $self, $name, $tests ) = @_;
266
+
267
+ my $pattern = $self->_glob_to_regexp($name);
268
+ $pattern = qr/^ $pattern $/x;
269
+ my @match = ();
270
+
271
+ for ( my $ti = 0; $ti < @$tests; $ti++ ) {
272
+ if ( $tests->[$ti]->filename =~ $pattern ) {
273
+ push @match, splice @$tests, $ti, 1;
274
+ $ti--;
275
+ }
276
+ }
277
+
278
+ return @match;
279
+ }
280
+
281
+ =head2 Instance Methods
282
+
283
+ =head3 C<get_all>
284
+
285
+ Get a list of all remaining tests.
286
+
287
+ =cut
288
+
289
+ sub get_all {
290
+ my $self = shift;
291
+ my @all = $self->_gather( $self->{schedule} );
292
+ $self->{count} = @all;
293
+ @all;
294
+ }
295
+
296
+ sub _gather {
297
+ my ( $self, $rule ) = @_;
298
+ return unless defined $rule;
299
+ return $rule unless 'ARRAY' eq ref $rule;
300
+ return map { defined() ? $self->_gather($_) : () } map {@$_} @$rule;
301
+ }
302
+
303
+ =head3 C<get_job>
304
+
305
+ Return the next available job as L<TAP::Parser::Scheduler::Job> object or
306
+ C<undef> if none are available. Returns a L<TAP::Parser::Scheduler::Spinner> if
307
+ the scheduler still has pending jobs but none are available to run right now.
308
+
309
+ =cut
310
+
311
+ sub get_job {
312
+ my $self = shift;
313
+ $self->{count} ||= $self->get_all;
314
+ my @jobs = $self->_find_next_job( $self->{schedule} );
315
+ if (@jobs) {
316
+ --$self->{count};
317
+ return $jobs[0];
318
+ }
319
+
320
+ return TAP::Parser::Scheduler::Spinner->new
321
+ if $self->{count};
322
+
323
+ return;
324
+ }
325
+
326
+ sub _not_empty {
327
+ my $ar = shift;
328
+ return 1 unless 'ARRAY' eq ref $ar;
329
+ for (@$ar) {
330
+ return 1 if _not_empty($_);
331
+ }
332
+ return;
333
+ }
334
+
335
+ sub _is_empty { !_not_empty(@_) }
336
+
337
+ sub _find_next_job {
338
+ my ( $self, $rule ) = @_;
339
+
340
+ my @queue = ();
341
+ my $index = 0;
342
+ while ( $index < @$rule ) {
343
+ my $seq = $rule->[$index];
344
+
345
+ # Prune any exhausted items.
346
+ shift @$seq while @$seq && _is_empty( $seq->[0] );
347
+ if (@$seq) {
348
+ if ( defined $seq->[0] ) {
349
+ if ( 'ARRAY' eq ref $seq->[0] ) {
350
+ push @queue, $seq;
351
+ }
352
+ else {
353
+ my $job = splice @$seq, 0, 1, undef;
354
+ $job->on_finish( sub { shift @$seq } );
355
+ return $job;
356
+ }
357
+ }
358
+ ++$index;
359
+ }
360
+ else {
361
+
362
+ # Remove the empty sub-array from the array
363
+ splice @$rule, $index, 1;
364
+ }
365
+ }
366
+
367
+ for my $seq (@queue) {
368
+ if ( my @jobs = $self->_find_next_job( $seq->[0] ) ) {
369
+ return @jobs;
370
+ }
371
+ }
372
+
373
+ return;
374
+ }
375
+
376
+ =head3 C<as_string>
377
+
378
+ Return a human readable representation of the scheduling tree.
379
+ For example:
380
+
381
+ my @tests = (qw{
382
+ t/startup/foo.t
383
+ t/shutdown/foo.t
384
+
385
+ t/a/foo.t t/b/foo.t t/c/foo.t t/d/foo.t
386
+ });
387
+ my $sched = TAP::Parser::Scheduler->new(
388
+ tests => \@tests,
389
+ rules => {
390
+ seq => [
391
+ { seq => 't/startup/*.t' },
392
+ { par => ['t/a/*.t','t/b/*.t','t/c/*.t'] },
393
+ { seq => 't/shutdown/*.t' },
394
+ ],
395
+ },
396
+ );
397
+
398
+ Produces:
399
+
400
+ par:
401
+ seq:
402
+ par:
403
+ seq:
404
+ par:
405
+ seq:
406
+ 't/startup/foo.t'
407
+ par:
408
+ seq:
409
+ 't/a/foo.t'
410
+ seq:
411
+ 't/b/foo.t'
412
+ seq:
413
+ 't/c/foo.t'
414
+ par:
415
+ seq:
416
+ 't/shutdown/foo.t'
417
+ 't/d/foo.t'
418
+
419
+
420
+ =cut
421
+
422
+
423
+ sub as_string {
424
+ my $self = shift;
425
+ return $self->_as_string( $self->{schedule} );
426
+ }
427
+
428
+ sub _as_string {
429
+ my ( $self, $rule, $depth ) = ( shift, shift, shift || 0 );
430
+ my $pad = ' ' x 2;
431
+ my $indent = $pad x $depth;
432
+ if ( !defined $rule ) {
433
+ return "$indent(undef)\n";
434
+ }
435
+ elsif ( 'ARRAY' eq ref $rule ) {
436
+ return unless @$rule;
437
+ my $type = ( 'par', 'seq' )[ $depth % 2 ];
438
+ return join(
439
+ '', "$indent$type:\n",
440
+ map { $self->_as_string( $_, $depth + 1 ) } @$rule
441
+ );
442
+ }
443
+ else {
444
+ return "$indent'" . $rule->filename . "'\n";
445
+ }
446
+ }
447
+
448
+ 1;