X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Flibstatistics-r-perl.git;a=blobdiff_plain;f=t%2F03-run.t;fp=t%2F03-run.t;h=a8889ab2b13c1d01f05e1e431d0c7e8b85df1a6d;hp=cf3ea5adcb24f1417b5deee81190a0e4d398dfb8;hb=713b845d0db50899e64c616b0b43b6180b862afa;hpb=fea5b01e0da1d4f97108cf08c424d5ef4f66a64f diff --git a/t/03-run.t b/t/03-run.t index cf3ea5a..a8889ab 100644 --- a/t/03-run.t +++ b/t/03-run.t @@ -3,27 +3,37 @@ use strict; use warnings; use Test::More; +use File::Copy; +use File::Temp; use Statistics::R; +use File::Spec::Functions; -plan tests => 15; - - -my ($R, $expected); +my ($R, $expected, $bin, $version); my $file = 'file.ps'; ok $R = Statistics::R->new(); -ok $R->bin() =~ /\S+/, 'Binary'; +ok $bin = $R->bin(); +ok $bin =~ /\S+/, 'Executable name'; $expected = ''; is $R->run( ), $expected; +ok $bin = $R->bin(); +ok $bin =~ /\S+/, 'Executable path'; + +ok $version = $R->version(); +ok $version =~ /^\d+\.\d+\.\d+$/, 'Version'; + +diag "R version $version found at $bin\n"; + + $expected = ''; is $R->run( qq`postscript("$file" , horizontal=FALSE , width=500 , height=500 , pointsize=1)`), $expected, 'Basic'; $expected = ''; -is $R->run( q`plot(c(1, 5, 10), type = "l")` ), $expected; +is $R->run( q`plot(c(1, 5, 10), type = "l");` ), $expected; $expected = 'null device @@ -76,5 +86,11 @@ Some innocuous message on stdout [1] 123 456 [1] "ok"'; -is $R->run_from_file( './t/data/script.R' ), $expected, 'Commands from file'; +$file = catfile('t', 'data', 'script.R'); +is $R->run_from_file( $file ), $expected, 'Command from file (relative path)'; + +my $absfile = File::Temp->new( UNLINK => 1 )->filename; +copy($file, $absfile) or die "Error: Could not copy file $file to $absfile: $!\n"; +is $R->run_from_file( $absfile ), $expected, 'Commands from file (absolute path)'; +done_testing;