develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33937 - trunk/t/compilers/pct

From:
particle
Date:
December 15, 2008 14:56
Subject:
[svn:parrot] r33937 - trunk/t/compilers/pct
Message ID:
20081215225611.58C3ACBA12@x12.develooper.com
Author: particle
Date: Mon Dec 15 14:56:10 2008
New Revision: 33937

Modified:
   trunk/t/compilers/pct/complete_workflow.t

Log:
[t] increased use of parrot test library functions, portability, test description accuracy, documentation. also fixes six failing tests on MSWin32

Modified: trunk/t/compilers/pct/complete_workflow.t
==============================================================================
--- trunk/t/compilers/pct/complete_workflow.t	(original)
+++ trunk/t/compilers/pct/complete_workflow.t	Mon Dec 15 14:56:10 2008
@@ -317,11 +317,12 @@
          UNLINK   => 1,
     };
 
-    my $sample_fn = 'complete_workflow_sample_input.txt';
-    Parrot::Test::write_code_to_file( $in, $sample_fn );
-
     # this will be passed to pir_output_is()
-    my $pir_code = <<'EOT';
+    my $pir_code = <<"EOT";
+#------------------------------#
+# The compiler mainline code   #
+#------------------------------#
+
 .namespace [ 'TestGrammar'; 'Compiler' ]
 
 .sub 'onload' :anon :load :init
@@ -333,14 +334,14 @@
     .local pmc args
     args = new 'ResizableStringArray'
     push args, "test_program"
-    push args, "complete_workflow_sample_input.txt"
+    push args, "$TEST_DIR/complete_workflow_sample_input.txt"
 
-    $P0 = new ['PCT'; 'HLLCompiler']
-    $P0.'language'('TestGrammar')
-    $P0.'parsegrammar'('TestGrammar::Grammar')
-    $P0.'parseactions'('TestGrammar::Grammar::Actions')
+    \$P0 = new ['PCT'; 'HLLCompiler']
+    \$P0.'language'('TestGrammar')
+    \$P0.'parsegrammar'('TestGrammar::Grammar')
+    \$P0.'parseactions'('TestGrammar::Grammar::Actions')
 
-    $P1 = $P0.'command_line'(args)
+    \$P1 = \$P0.'command_line'(args)
 
     .return()
 .end
@@ -348,8 +349,8 @@
 EOT
 
     # set up a file with the grammar
-    my ($PG, $pg_fn) = create_tempfile( SUFFIX => '.pg', %$tempfile_opts );
-    print $PG <<"EOT";
+    my (undef, $pg_fn) = create_tempfile( SUFFIX => '.pg', %$tempfile_opts );
+    Parrot::Test::write_code_to_file( <<"EOT", $pg_fn );
 # DO NOT EDIT.
 # This file was generated by t/compilers/pct/complete_workflow.t
 
@@ -367,12 +368,10 @@
     # that is passed to pir_output_is().
     ( my $gen_parser_fn = $pg_fn ) =~s/pg$/pir/;
     my $rv = Parrot::Test::run_command(
-       qq{$PARROT $PERL6GRAMMAR $pg_fn},
-       STDOUT => $gen_parser_fn,
-       STDERR => $gen_parser_fn,
+       qq{$PARROT $PERL6GRAMMAR --output=$gen_parser_fn $pg_fn},
     );
     is( $rv, 0, "$test_name: generated PIR successfully" );
-    ok( -e $gen_parser_fn, "$test_name: generated parser exist" );
+    ok( -e $gen_parser_fn, "$test_name: generated parser file exists" );
     my $gen_parser = slurp_file($gen_parser_fn);
     unlink $gen_parser_fn;
 
@@ -387,8 +386,8 @@
 
 
     # set up a file with the actions
-    my ($PM, $pm_fn) = create_tempfile( SUFFIX => '.pm', %$tempfile_opts );
-    print $PM <<"EOT";
+    my (undef, $pm_fn) = create_tempfile( SUFFIX => '.pm', %$tempfile_opts );
+    Parrot::Test::write_code_to_file( <<"EOT", $pm_fn );
 # DO NOT EDIT.
 # This file was generated by t/compilers/pct/complete_workflow.t
 
@@ -402,14 +401,12 @@
     ok( -e $pm_fn, "$test_name: action file exists" );
 
     # compile the actions
-    ( my $gen_actions_fn = $pm_fn ) =~s/nqp$/pir/;
+    ( my $gen_actions_fn = $pm_fn ) =~s/pm$/pir/;
     $rv = Parrot::Test::run_command(
-       qq{$PARROT $NQP --target=pir $pm_fn},
-       STDOUT => $gen_actions_fn,
-       STDERR => $gen_actions_fn,
+        qq{$PARROT $NQP --target=pir --output=$gen_actions_fn $pm_fn},
     );
     is( $rv, 0, "$test_name: generated PIR successfully" );
-    ok( -e $gen_actions_fn, "$test_name: generated actions exist" );
+    ok( -e $gen_actions_fn, "$test_name: generated actions file exists" );
     my $gen_actions = slurp_file($gen_actions_fn);
     unlink $gen_actions_fn;
 
@@ -425,6 +422,10 @@
 
 EOT
 
+    # create the input file and run the compiled code
+    my $sample_fn = "$TEST_DIR/complete_workflow_sample_input.txt";
+    Parrot::Test::write_code_to_file( $in, $sample_fn );
+
     pir_output_is( $pir_code, $out, "$test_name: output of compiler", @other );
 
     unlink $sample_fn;



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About