citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit a55c54f1c1786909d522c483c6e09bab3e92b2bc
parent be0e83098a722521c7d1049da88e7ef3b0a5c2f5
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Thu, 16 Jun 2016 21:55:46 -0600

Test: just parse the output of some os specific commands

Diffstat:
MTest/Package.pm | 25+++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/Test/Package.pm b/Test/Package.pm @@ -30,8 +30,8 @@ sub dependencies { my ($self, @deps) = @_; my @installed_pkgs; - @installed_pkgs = get_installed_obsd() if ($^O eq "openbsd"); - @installed_pkgs = get_installed_darwin() if ($^O eq "darwin"); + @installed_pkgs = parse_output('pkg_info', '-q') if ($^O eq "openbsd"); + @installed_pkgs = parse_output('port', 'installed') if ($^O eq "darwin"); my @missing_deps; for my $dep (@deps) { @@ -53,26 +53,15 @@ sub dependencies { } } -sub get_installed_obsd { - my $pid = open2(\*CHLD_OUT, undef, 'pkg_info', '-q'); - waitpid( $pid, 0 ); - my $pkg_info_exit_code = $? >> 8; - - my @installed_pkgs; - push @installed_pkgs, ($_) while (readline \*CHLD_OUT); +sub parse_output { + my $pid = open2(\*CHLD_OUT, undef, @_); - return @installed_pkgs; -} - -sub get_installed_darwin { - my $pid = open2(\*CHLD_OUT, undef, 'port', 'installed'); waitpid( $pid, 0 ); my $pkg_info_exit_code = $? >> 8; - my @installed_pkgs; - push @installed_pkgs, ($_) while (readline \*CHLD_OUT); - - return @installed_pkgs; + my @pkgs; + push @pkgs, ($_) while (readline \*CHLD_OUT); + return @pkgs; } 1;