Skip to content

Commit

Permalink
Issue #192: don't try to print test result
Browse files Browse the repository at this point in the history
while STDOUT is still redirected to a Perl scalar
  • Loading branch information
bschmalhofer committed Sep 25, 2020
1 parent fc98986 commit e9dd49e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions scripts/test/Console/Command/Dev/Tools/Migrate/ConfigXMLStructure.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use Path::Class qw(dir file);

# OTOBO modules

use vars (qw($Self));
our $Self;

$Self->Plan( Tests => 6 );

Expand All @@ -39,12 +39,15 @@ my $Home = $Kernel::OM->Get('Kernel::Config')->Get('Home');

# error with non-existent dir
{
local *STDOUT;
open STDOUT, '>:encoding(UTF-8)', \my $Result;
my $ExitCode = $CommandObject->Execute( "--source-directory", "$Home/Kernel/Config/Files/NotExisting/" );
$Kernel::OM->Get('Kernel::System::Encode')->EncodeInput( \$Result );
my ($ExitCode, $Result);
{
local *STDOUT;
open STDOUT, '>:encoding(UTF-8)', \$Result;
$ExitCode = $CommandObject->Execute( "--source-directory", "$Home/Kernel/Config/Files/NotExisting/" );
}
$Self->Note( Note => $Result );

# exit code 1 indicates failure
$Self->Is(
$ExitCode,
1,
Expand All @@ -62,12 +65,15 @@ my $Home = $Kernel::OM->Get('Kernel::Config')->Get('Home');
my $SampleFile = dir($Home)->file('scripts/test/sample/SysConfig/ConfigurationMigrateXMLStructure.xml');
my $WorkFile = $SampleFile->copy_to( $TestDir->file('ConfigurationMigrateXMLStructure.xml') );

local *STDOUT;
open STDOUT, '>:encoding(UTF-8)', \my $Result;
my $ExitCode = $CommandObject->Execute( "--source-directory", $TestDir->stringify );
$Kernel::OM->Get('Kernel::System::Encode')->EncodeInput( \$Result );
my ($ExitCode, $Result);
{
local *STDOUT;
open STDOUT, '>:encoding(UTF-8)', \$Result;
$ExitCode = $CommandObject->Execute( "--source-directory", $TestDir->stringify );
}
$Self->Note( Note => $Result );

# exit code 0 indicates success
$Self->Is(
$ExitCode,
0,
Expand Down Expand Up @@ -104,5 +110,3 @@ my $Home = $Kernel::OM->Get('Kernel::Config')->Get('Home');
"Content of $WorkFile"
);
}


0 comments on commit e9dd49e

Please sign in to comment.