#!/usr/local/bin/perl -w
if
(!(-d
"t"
)) {
print
STDERR
"Error - program must be run from UMLS::Similarity\n"
;
print
STDERR
"directory as : perl t/getCompounds.t \n"
;
exit
;
}
my
%option_hash
= ();
$option_hash
{
"realtime"
} = 1;
$option_hash
{
"t"
} = 1;
my
$umls
= UMLS::Interface->new(\
%option_hash
);
ok(
$umls
);
my
$version
=
$umls
->version();
my
$keydir
= File::Spec->catfile(
't'
,
'key'
,
$version
);
if
(! (-e
$keydir
) ) {
File::Path->make_path(
$keydir
);
}
my
$perl
= $^X;
my
$util_prg
= File::Spec->catfile(
'utils'
,
'getCompounds.pl'
);
my
(
$keyfile
,
$file
,
$output
,
$config
);
$file
=
"getCompounds.mth.rb-rn"
;
$keyfile
= File::Spec->catfile(
$keydir
,
$file
);
$config
= File::Spec->catfile(
't'
,
'config'
,
'config.mth.rb-rn'
);
$output
= `
$perl
$util_prg
$config
2>&1`;
if
(-e
$keyfile
) {
ok (
open
KEY,
$keyfile
) or diag
"Could not open $keyfile: $!"
;
my
$key
=
""
;
while
(<KEY>) {
$key
.=
$_
; }
close
KEY;
cmp_ok(
$output
,
'eq'
,
$key
);
}
else
{
ok(
open
KEY,
">$keyfile"
) || diag
"Could not open $keyfile: $!"
;
print
KEY
$output
;
close
KEY;
SKIP: {
skip (
"Generating key, no need to run test"
, 1);
}
}