Skip to content

Commit

Permalink
Item13405: Wide char in print in bootstrap, unit tests
Browse files Browse the repository at this point in the history
Also unit tests fail if the file system path contains non-ASCII
characters.

And the Extensions installer fails if non-ASCII in path.
  • Loading branch information
gac410 committed Dec 24, 2015
1 parent 1db9068 commit be33f8f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
8 changes: 5 additions & 3 deletions RCSStoreContrib/test/unit/RCSStoreContrib/AutoAttachTests.pm
Expand Up @@ -111,9 +111,11 @@ sub sneakAttachmentsAddedToTopic {

sub touchFile {
my $filename = shift;
open( FILE, ">$filename" );
print FILE "Test attachment $filename\n";
close(FILE);
$filename = Encode::encode_utf8($filename);
open( my $fh, ">$filename" );
binmode $fh, ":encoding(utf-8)";
print $fh "Test attachment $filename\n";
close($fh);
}

sub verify_autoattach {
Expand Down
9 changes: 8 additions & 1 deletion UnitTestContrib/test/unit/FoswikiStoreTestCase.pm
Expand Up @@ -97,7 +97,14 @@ sub fixture_groups {

#return ( [ 'PlainFile' ], [ 'utf8' ] );
if ($Foswiki::UNICODE) {
return ( \@groups, [ 'iso8859', 'utf8', ] );
if ( Cwd::cwd() =~ m/[^\p{ASCII}]/ ) {
print STDERR
"SKIPPING iso8859 tests: Path contains non-ASCII Characters\n";
return ( \@groups, [ 'utf8', ] );
}
else {
return ( \@groups, [ 'iso8859', 'utf8', ] );
}
}
else {
return \@groups;
Expand Down
23 changes: 23 additions & 0 deletions UnitTestContrib/test/unit/UploadScriptTests.pm
Expand Up @@ -39,6 +39,29 @@ sub set_up {
return;
}

sub skip {
my ( $this, $test ) = @_;

my %skip_tests;

if ( Cwd::cwd() =~ m/[^\p{ASCII}]/ ) {

%skip_tests = (
'UploadScriptTests::test_unsupported_characters' =>
'Tests for iso-8859 character sets not supported: Path contains non-ASCII characters',
'UploadScriptTests::test_supported_nonascii' =>
'Tests for iso-8859 character sets not supported: Path contains non-ASCII characters',
);

return $skip_tests{$test}
if ( defined $test && defined $skip_tests{$test} );

}

return undef;

}

sub do_upload {
my ( $this, $fn, $data, $cuid, @arga ) = @_;
my %params = @arga;
Expand Down
5 changes: 3 additions & 2 deletions core/lib/Foswiki/Configure/Load.pm
Expand Up @@ -416,7 +416,7 @@ sub bootstrapConfig {

# Can't use Foswiki::decode_utf8 - this is too early in initialization
print STDERR "AUTOCONFIG: Found Bin dir: "
. NFC( Encode::decode_utf8($bin) )
. $bin
. ", Script name: $script using FindBin\n"
if (TRAUTO);

Expand Down Expand Up @@ -465,7 +465,8 @@ sub bootstrapConfig {
# Can't use Foswiki::decode_utf8 - this is too early in initialization
$Foswiki::cfg{$key} = NFC( Encode::decode_utf8( $Foswiki::cfg{$key} ) );

print STDERR "AUTOCONFIG: $key = $Foswiki::cfg{$key} \n"
print STDERR "AUTOCONFIG: $key = "
. Encode::encode_utf8( $Foswiki::cfg{$key} ) . "\n"
if (TRAUTO);

if ( -d $Foswiki::cfg{$key} ) {
Expand Down
4 changes: 3 additions & 1 deletion core/lib/Foswiki/Configure/Package.pm
Expand Up @@ -248,7 +248,9 @@ sub option {
}
}

if ( open( my $file, '>>', $this->{_logfile} ) ) {
if ( open( my $file, '>>', Foswiki::encode_utf8( $this->{_logfile} ) ) )
{
binmode $file, ":encoding(utf-8)";
print $file $text;
close($file);
}
Expand Down

0 comments on commit be33f8f

Please sign in to comment.