--- messaging/manakai/bin/daf.pl 2006/03/12 10:13:31 1.5 +++ messaging/manakai/bin/daf.pl 2006/04/04 14:30:29 1.11 @@ -34,6 +34,7 @@ 'debug' => \$Opt{debug}, 'dis-file-suffix=s' => \$Opt{dis_suffix}, 'daem-file-suffix=s' => \$Opt{daem_suffix}, + 'dafs-file-suffix=s' => \$Opt{dafs_suffix}, 'dafx-file-suffix=s' => \$Opt{dafx_suffix}, 'help' => \$Opt{help}, 'search-path|I=s' => sub { @@ -82,6 +83,7 @@ $Opt{dis_suffix} = '.dis' unless defined $Opt{dis_suffix}; $Opt{daem_suffix} = '.dafm' unless defined $Opt{daem_suffix}; $Opt{dafx_suffix} = '.dafx' unless defined $Opt{dafx_suffix}; +$Opt{dafs_suffix} = '.dafs' unless defined $Opt{dafs_suffix}; $Message::DOM::DOMFeature::DEBUG = 1 if $Opt{debug}; require Error; $Error::Debug = 1 if $Opt{debug}; @@ -133,8 +135,6 @@ %feature, }); my $impl = $limpl->get_feature (ExpandedURI q => '1.0'); -my $pc = $impl->get_feature (ExpandedURI q => '1.0'); -my $di = $impl->get_feature (ExpandedURI q => '1.0'); my $tdt_parser; ## --- Loading and Updating the Database @@ -295,7 +295,10 @@ if ($out_type eq 'perl-pm') { status_msg_ qq for <$mod_for>...>; - my $pl = $mod->pl_generate_perl_module_file; + local $Message::Util::DIS::Perl::Implementation + = $impl->get_feature (ExpandedURI q => '1.0'); + my $pl = $mod->pl_generate_perl_module_file + ($impl->get_feature (ExpandedURI q => '1.0')); status_msg qq; my $output; @@ -342,6 +345,9 @@ undef $db; status_msg "done"; +undef $limpl; +undef $impl; + { use integer; my $time = time - $start_time; @@ -480,7 +486,7 @@ sub dac_search_file_path_stem ($$$) { my ($ns, $ln, $suffix) = @_; require File::Spec; - for my $dir ('.', @{$Opt{input_search_path}->{$ns}||[]}) { + for my $dir (@{$Opt{input_search_path}->{$ns}||[]}) { my $name = Cwd::abs_path (File::Spec->canonpath (File::Spec->catfile ($dir, $ln))); @@ -539,8 +545,11 @@ my ($db, $mod, $type) = @_; my $ns = $mod->namespace_uri; my $ln = $mod->local_name; - my $suffix = $type eq ExpandedURI q - ? $Opt{dafx_suffix} : $Opt{daem_suffix}; + my $suffix = { + ExpandedURI q => $Opt{dafx_suffix}, + ExpandedURI q => $Opt{daem_suffix}, + ExpandedURI q => $Opt{dafs_suffix}, + }->{$type} or die "Unsupported type: <$type>"; verbose_msg qq is requested>; my $name = dac_search_file_path_stem ($ns, $ln, $suffix); if (defined $name) { @@ -585,7 +594,10 @@ sub daf_generate_perl_test_file ($) { my $mod = shift; - my $pl = $pc->create_perl_file; + my $pc = $impl->get_feature (ExpandedURI q => '1.0'); + local $Message::Util::DIS::Perl::Implementation = $pc; + my $pl = $pc->create_pc_file; + my $factory = $pl->owner_document; my $pack = $pl->get_last_package ("Manakai::Test", make_new_package => 1); $pack->add_use_perl_module_name ("Message::Util::DIS::Test"); $pack->add_use_perl_module_name ("Message::Util::Error"); @@ -597,6 +609,23 @@ $pl->license_uri ($mod->get_property_resource (ExpandedURI q) ->uri); + $pack->append_code (' + use Getopt::Long; + my %Skip; + GetOptions ( + "Skip=s" => sub { + shift; + for (split /\s+/, shift) { + if (/^(\d+)-(\d+)$/) { + $Skip{$_} = 1 for $1..$2; + } else { + $Skip{$_} = 1; + } + } + }, + ); + '); + $pack->append_code ($pc->create_perl_statement ('my $impl = $Message::DOM::ImplementationRegistry->get_implementation ({ @@ -616,14 +645,20 @@ if ($res->is_type_uri (ExpandedURI q)) { if ($res->is_type_uri (ExpandedURI q)) { - $total_tests++; + my $test_num = ++$total_tests; + my $test_uri = $res->name_uri || $res->uri; + $pack->append_code ('$test->start_new_test ('); - $pack->append_new_pc_literal ($res->name_uri || $res->uri); + $pack->append_new_pc_literal ($test_uri); $pack->append_code (');'); + + $pack->append_code ('if (not $Skip{'.$test_num.'} and not $Skip{'); + $pack->append_new_pc_literal ($test_uri); + $pack->append_code ('}) {'); $pack->append_code ('try {'); - my $test_pc = $res->pl_code_fragment; + my $test_pc = $res->pl_code_fragment ($factory); if (not defined $test_pc) { die "Perl test code not defined for <".$res->uri.">"; } @@ -640,6 +675,8 @@ $test->not_ok; };'); + $pack->append_code ('} else { warn "'.$test_num.' skipped\n" }'); + } elsif ($res->is_type_uri (ExpandedURI q)) { my $block = $pack->append_new_pc_block; my @test; @@ -666,6 +703,15 @@ not defined $ttest->{root_uri}; } + ## DOM configuration parameters + for my $v (@{$tres->get_property_value_list + (ExpandedURI q)}) { + my $cpuri = $v->name; + my $cp = $db->get_resource ($cpuri, for_arg => $tres->for_uri); + $ttest->{dom_config}->{$cp->get_dom_configuration_parameter_name} + = $v->get_perl_code ($block->owner_document, $tres); + } + ## Result DOM tree my $tree_t = $tres->get_property_text (ExpandedURI q); if (defined $tree_t) { @@ -688,7 +734,7 @@ $_->append_new_pc_literal (\@test); } - my $plc = $res->pl_code_fragment; + my $plc = $res->pl_code_fragment ($factory); unless ($plc) { die "Resource <".$res->uri."> does not have Perl test code"; }