1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#!/usr/bin/perl
use strict;
use Test::More;
use Dpkg::IPC;
my @tests = (
# Simple package
'abab' => '/usr/share/nodejs/abab',
'-p abab' => 'node-abab: /usr/share/nodejs/abab',
'-o abab' => 'node-abab',
# Module
'slice-ansi' => '/usr/share/nodejs/slice-ansi',
'-p slice-ansi' => 'node-slice-ansi: /usr/share/nodejs/slice-ansi',
'@mdn/browser-compat-data' => '/usr/share/nodejs/@mdn/browser-compat-data',
'-o @mdn/browser-compat-data' => 'node-mdn-browser-compat-data',
# Typescript types
'@types/node' => '/usr/share/nodejs/@types/node',
# Unexistent
'@types/_zz' => 'STDERR:Not found',
);
plan tests => scalar @tests;
for ( my $i = 0 ; $i < @tests ; $i += 2 ) {
my ( $args, $res ) = ( $tests[$i], $tests[ $i + 1 ] );
my ( $out, $err );
spawn(
exec => [ 'nodepath', split( /\s+/, $args ) ],
no_check => 1,
# XXX: Backwards compatibility, remove after dpkg 1.24.0.
nocheck => 1,
wait_child => 1,
to_string => \$out,
error_to_string => \$err,
);
my $status = $?;
chomp $out;
chomp $err;
if ( $res =~ s/STDERR:// ) {
ok( $status, "'nodepath $args' failed" );
ok( $err eq $res, "error matches: $res" )
or diag "Received: \n OUT: $out\n ERR: $err";
}
else {
ok( !$status, "'nodepath $args' succeeded" );
ok( $out eq $res, "result matches: $res" )
or diag "Received: \n OUT: $out\n ERR: $err";
}
}
|