]> sipb.mit.edu Git - ikiwiki.git/commitdiff
don't edit config setting, but a temporary variable, complete and unbreak tests
authorAntoine Beaupré <anarcat@koumbit.org>
Sat, 7 Sep 2013 22:50:53 +0000 (18:50 -0400)
committerAntoine Beaupré <anarcat@koumbit.org>
Fri, 29 Nov 2013 06:09:04 +0000 (01:09 -0500)
IkiWiki.pm
t/syslog.t

index 2c0b1153c906c7a3fb33d0d575cfca1d87787946..86c8508119fa203bd5ed372b777c6a1fe054e138 100644 (file)
@@ -740,7 +740,10 @@ sub log_message ($$) {
                        $log_open=1;
                }
                eval {
-                       Sys::Syslog::syslog($type, "[$config{wikiname}] %s", join(" ", @_));
+                       # keep a copy to avoid editing the original config repeatedly
+                       my $wikiname = $config{wikiname};
+                       utf8::encode($wikiname);
+                       Sys::Syslog::syslog($type, "[$wikiname] %s", join(" ", @_));
                };
                 if ($@) {
                     print STDERR "failed to syslog: $@" unless $log_failed;
index 28272e2dcf9fcd872d4d49660c1b9cf07f26bf3f..ffe8635b3e72f975577faa1bf1e5d1d310842281 100644 (file)
@@ -1,14 +1,18 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 3;
+use Test::More tests => 5;
 use utf8;
 
 BEGIN { use_ok("IkiWiki"); }
 
 $IkiWiki::config{verbose} = 1;
 $IkiWiki::config{syslog} = 1;
-$IkiWiki::config{wikiname} = 'ascii';
-is(debug('test'), '');
+
+$IkiWiki::config{wikiname} = 'ASCII';
+is(debug('test'), '', 'plain ASCII syslog');
 $IkiWiki::config{wikiname} = 'not ⒶSCII';
-is(debug('test'), '');
+is(debug('test'), '', 'UTF8 syslog');
+my $orig = $IkiWiki::config{wikiname};
+is(debug('test'), '', 'check for idempotency');
+is($IkiWiki::config{wikiname}, $orig, 'unchanged config');