summaryrefslogtreecommitdiff
blob: 6d703a9e1fc62e3d4e8d13d21b9e66b67342517e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
From 5f5a0a34556d0ae739f79d7c148d24fcf3ff8557 Mon Sep 17 00:00:00 2001
From: Kent Fredric <kentfredric@gmail.com>
Date: Wed, 3 Aug 2016 01:26:17 +1200
Subject: [PATCH] Fence of Network IO with NO_NETWORK_TESTING

This is a workaround for #477 but doesn't actually fix the underlying
issue, merely recognises that some vendors are smart enough to
anticipate Network IO will fail and integrate this ENV var to quickly
avoid it.

This precedent was established by Test::RequiresInternet as a result of
a CPANworkers discussion, and Gentoo is known to export this variable
within its tooling by default as a result.

This doesn't actually test that binding a socket/IP will work, but this
fence should be tested anyway, because security measures could result in
attempted socket/IP binds getting SIGKILLed ( Sandbox )

This commit hence addresses/fences only the problem cases listed in bug
in depth.

However, this commit targets to simply solve the known parts of the
problem in the simplest way possible without any extra dependencies.

The application of a BEGIN { } block and `print` was a design decision
instead of using `Test::More` and `skip`, because the overhead of
loading Test::More is quite high when you have lots of .t files, and
Test2 further increases the load time.

This load time is generally acceptable if you're actually running a
dozen tests, but spinning up a full suite of Test::More to only then
immediately exit with a skip is a lot of CPU load for relatively little
benefit.
---
 t/Plack-Handler/standalone.t                      | 6 ++++++
 t/Plack-Loader/shotgun.t                          | 6 ++++++
 t/Plack-Middleware/component-leak.t               | 7 +++++++
 t/Plack-Middleware/error_document_streaming_app.t | 7 +++++++
 t/Plack-Middleware/stacktrace/sigdie.t            | 7 +++++++
 t/Plack-Middleware/stacktrace/utf8.t              | 7 +++++++
 t/Plack-Middleware/urlmap_ports.t                 | 6 ++++++
 t/Plack-Test/2args.t                              | 7 +++++++
 t/Plack-Test/hello_server.t                       | 7 +++++++
 t/Plack-Util/response_cb.t                        | 7 +++++++
 10 files changed, 67 insertions(+)

diff --git a/t/Plack-Handler/standalone.t b/t/Plack-Handler/standalone.t
index f5fcf26..b42de16 100644
--- a/t/Plack-Handler/standalone.t
+++ b/t/Plack-Handler/standalone.t
@@ -1,3 +1,9 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
 use strict;
 use warnings;
 use Test::More;
diff --git a/t/Plack-Loader/shotgun.t b/t/Plack-Loader/shotgun.t
index cb7b95a..d9fe148 100644
--- a/t/Plack-Loader/shotgun.t
+++ b/t/Plack-Loader/shotgun.t
@@ -1,3 +1,9 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
 use strict;
 use warnings;
 use Test::More;
diff --git a/t/Plack-Middleware/component-leak.t b/t/Plack-Middleware/component-leak.t
index 7cdab99..2acedd0 100644
--- a/t/Plack-Middleware/component-leak.t
+++ b/t/Plack-Middleware/component-leak.t
@@ -1,3 +1,10 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
+
 package MyComponent;
 use strict;
 use warnings;
diff --git a/t/Plack-Middleware/error_document_streaming_app.t b/t/Plack-Middleware/error_document_streaming_app.t
index b177c53..c893e7b 100644
--- a/t/Plack-Middleware/error_document_streaming_app.t
+++ b/t/Plack-Middleware/error_document_streaming_app.t
@@ -1,3 +1,10 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
+
 use strict;
 use warnings;
 use FindBin;
diff --git a/t/Plack-Middleware/stacktrace/sigdie.t b/t/Plack-Middleware/stacktrace/sigdie.t
index dc82b2c..28747cf 100644
--- a/t/Plack-Middleware/stacktrace/sigdie.t
+++ b/t/Plack-Middleware/stacktrace/sigdie.t
@@ -1,3 +1,10 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
+
 use strict;
 use warnings;
 use Test::More;
diff --git a/t/Plack-Middleware/stacktrace/utf8.t b/t/Plack-Middleware/stacktrace/utf8.t
index 6d2f51f..77849dc 100644
--- a/t/Plack-Middleware/stacktrace/utf8.t
+++ b/t/Plack-Middleware/stacktrace/utf8.t
@@ -1,3 +1,10 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
+
 use strict;
 use warnings;
 use Test::More;
diff --git a/t/Plack-Middleware/urlmap_ports.t b/t/Plack-Middleware/urlmap_ports.t
index 9a0a9c0..4ff4ba5 100644
--- a/t/Plack-Middleware/urlmap_ports.t
+++ b/t/Plack-Middleware/urlmap_ports.t
@@ -1,3 +1,9 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
 use strict;
 use Test::More;
 use Plack::App::URLMap;
diff --git a/t/Plack-Test/2args.t b/t/Plack-Test/2args.t
index 2942f93..a68481d 100644
--- a/t/Plack-Test/2args.t
+++ b/t/Plack-Test/2args.t
@@ -1,3 +1,10 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
+
 use Plack::Test;
 use Test::More;
 use HTTP::Request::Common;
diff --git a/t/Plack-Test/hello_server.t b/t/Plack-Test/hello_server.t
index 47ffb75..dc9f4bd 100644
--- a/t/Plack-Test/hello_server.t
+++ b/t/Plack-Test/hello_server.t
@@ -1,3 +1,10 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
+
 use Test::More;
 use Plack::Test;
 
diff --git a/t/Plack-Util/response_cb.t b/t/Plack-Util/response_cb.t
index 813dc87..5cb31ba 100644
--- a/t/Plack-Util/response_cb.t
+++ b/t/Plack-Util/response_cb.t
@@ -1,3 +1,10 @@
+BEGIN {
+  if ( $ENV{NO_NETWORK_TESTING} ) {
+    print '1..0 # SKIP Network connections required for this test';
+    exit;
+  }
+}
+
 use strict;
 use warnings;
 use Plack::Util;
-- 
2.9.2