summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t
diff options
context:
space:
mode:
Diffstat (limited to 'debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t')
-rw-r--r--debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t40
1 files changed, 40 insertions, 0 deletions
diff --git a/debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t b/debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t
new file mode 100644
index 0000000..108e10c
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t
@@ -0,0 +1,40 @@
+#!perl
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil qw/t_start_file_watch t_file_watch_for
+ t_cmp t_catfile t_append_file/;
+
+plan tests => 5, need_fork;
+
+my $fn=t_catfile(Apache::Test::vars->{t_logs}, 'watch');
+unlink $fn;
+
+t_start_file_watch 'watch';
+
+my $pid;
+select undef, undef, undef, 0.1 until defined($pid=fork);
+unless ($pid) { # child
+ t_append_file $fn, "\nhuhu\n4 5 6 \nblabla\n";
+ for(1..3) {
+ select undef, undef, undef, 0.3;
+ t_append_file $fn, "$_ ";
+ }
+ t_append_file $fn, "\nhuhu\n4 5 6 \nblabla";
+ exit 0;
+}
+
+ok t_cmp t_file_watch_for('watch', qr/^1 2 3 $/, 2),
+ "1 2 3 \n", 'incomplete line';
+
+my @lines=t_file_watch_for('watch', qr/^\d \d \d $/, 2);
+ok t_cmp @lines, 2, '2 lines';
+ok t_cmp $lines[0], "huhu\n", '1st line';
+ok t_cmp $lines[1], "4 5 6 \n", 'found it';
+
+ok t_cmp t_file_watch_for('watch', qr/^\d \d \d $/, 0.3),
+ undef, 'timeout';
+
+waitpid $pid, 0;