Skip to content

Commit b4f25eb

Browse files
committed
Remove dependency on Boost.Thread for Boost.Asio unit tests.
1 parent e67db70 commit b4f25eb

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

asio/boostify.pl

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ sub copy_source_file
100100
my $is_xsl = 0;
101101
$is_xsl = 1 if ($from =~ /.xsl$/);
102102

103+
my $is_test = 0;
104+
$is_test = 1 if ($from =~ /tests\/unit/);
105+
103106
# Open the files.
104107
open(my $input, "<$from") or die("Can't open $from for reading");
105108
open(my $output, ">$to") or die("Can't open $to for writing");
@@ -180,22 +183,29 @@ sub copy_source_file
180183
print_line($output, $1 . "<boost/" . $2 . ">", $from, $lineno);
181184
if ($uses_asio_thread)
182185
{
183-
print_line($output, $1 . "<boost/thread/thread.hpp>", $from, $lineno);
186+
print_line($output, $1 . "<boost/thread/thread.hpp>", $from, $lineno) if (!$is_test);
184187
$uses_asio_thread = 0;
185188
}
186189
}
187190
elsif ($line =~ /^(# *include )[<"]boost\/.*[>"].*$/)
188191
{
189192
if (!$includes_asio && $uses_asio_thread)
190193
{
191-
print_line($output, $1 . "<boost/thread/thread.hpp>", $from, $lineno);
194+
print_line($output, $1 . "<boost/thread/thread.hpp>", $from, $lineno) if (!$is_test);
192195
$uses_asio_thread = 0;
193196
}
194197
print_line($output, $line, $from, $lineno);
195198
}
196-
elsif ($line =~ /# *include [<"]asio\/thread\.hpp[>"]/)
199+
elsif ($line =~ /^(# *include )[<"]asio\/thread\.hpp[>"]/)
197200
{
198-
# Line is removed.
201+
if ($is_test)
202+
{
203+
print_line($output, $1 . "<boost/asio/detail/thread.hpp>", $from, $lineno);
204+
}
205+
else
206+
{
207+
# Line is removed.
208+
}
199209
}
200210
elsif ($line =~ /(# *include )[<"]asio\/error_code\.hpp[>"]/)
201211
{
@@ -234,7 +244,14 @@ sub copy_source_file
234244
}
235245
elsif ($line =~ /asio::thread/)
236246
{
237-
$line =~ s/asio::thread/boost::thread/g;
247+
if ($is_test)
248+
{
249+
$line =~ s/asio::thread/asio::detail::thread/g;
250+
}
251+
else
252+
{
253+
$line =~ s/asio::thread/boost::thread/g;
254+
}
238255
if (!($line =~ /boost::asio::/))
239256
{
240257
$line =~ s/asio::/boost::asio::/g;
@@ -243,11 +260,14 @@ sub copy_source_file
243260
}
244261
elsif ($line =~ /^( *)thread( .*)$/ && !$is_qbk)
245262
{
246-
if (!($line =~ /boost::asio::/))
263+
if ($is_test)
247264
{
248-
$line =~ s/asio::/boost::asio::/g;
265+
print_line($output, $1 . "boost::asio::detail::thread" . $2, $from, $lineno);
266+
}
267+
else
268+
{
269+
print_line($output, $1 . "boost::thread" . $2, $from, $lineno);
249270
}
250-
print_line($output, $1 . "boost::thread" . $2, $from, $lineno);
251271
}
252272
elsif ($line =~ /namespace std {/)
253273
{

0 commit comments

Comments
 (0)