Not sure if this is the best tack, but the below patch seems
to do the trick. What was happening was eval would barf when
it got the unquoted /foo/bar. Wrap the string in ""'s and
the error goes away. This snippet illustrates the problem:

$ perl -e 'eval "\"/foo/bar\"";'
$ perl -e 'eval "/foo/bar";'
Bareword found where operator expected at (eval 1) line 1,
near "/foo/bar"
        (Missing operator before bar?)


Index: /workspace/em162155/hpc/mtt/schema2/trunk/lib/MTT/Values.pm
===================================================================
--- /workspace/em162155/hpc/mtt/schema2/trunk/lib/MTT/Values.pm (revision 410)
+++ /workspace/em162155/hpc/mtt/schema2/trunk/lib/MTT/Values.pm (working copy)
@@ -46,7 +46,7 @@
         # If we get a string back, just handle it.
         if (ref($ret) eq "") {
             # Substitute in the $ret in place of the &function(...)
-            $str =~ s/(\&\w+\([^&\(]*?\))/$ret/;
+            $str =~ s/(\&\w+\([^&\(]*?\))/"$ret"/;
             Debug("String now: $str\n");

             # Now loop around and see if there are any more
@@ -92,7 +92,14 @@
         return \@ret;
     }

-#    Debug("No more functions left; final: $str\n");
+    Debug("No more functions left; final: $str\n");
+    return trim_quotes($str);
+}
+
+# Trim leading/trailing quotes
+sub trim_quotes {
+    my ($str) = @_;
+    $str =~ s/^\"+|\"+$//g;
     return $str;
 }

-Ethan


On Thu, Nov/02/2006 02:18:06PM, Ethan Mallove wrote:
> I need to compile a testsuite like this:
> 
> shell_build_command = &join("configure --with-lib-mpi=", &test_prefix(), 
> "gmake")
> 
> But MTT errors out with:
> 
> Building Shell
> Evaluating: &join("configure --with-lib-mpi=", &test_prefix(), "gmake")
> Got name: test_prefix
> Got args:
> _do: $ret = MTT::Values::Functions::test_prefix()
> &test_prefix returning: my_mpi/install/dir
> String now: &join("configure --with-lib-mpi=", my_mpi/install/dir, "gmake")
> Got name: join
> Got args: "configure --with-lib-mpi=", my_mpi/install/dir, "gmake"
> _do: $ret = MTT::Values::Functions::join("configure --with-lib-mpi=", 
> my_mpi/install/dir, "gmake")
> Bareword found where operator expected at (eval 33) line 1, near "/opt/mtt"
>         (Missing operator before tt?)
> Bareword found where operator expected at (eval 33) line 1, near "1.3a1r12364"
>         (Missing operator before a1r12364?)
> *** ERROR: Module aborted: MTT::Test::Build::Shell:Build: *** ERROR: Could 
> not evaluate: $ret = MTT::Values::Functions::join("configure 
> --with-lib-mpi=", my_mpi/install/dir, "gmake"): syntax error at (eval 33) 
> line 1, near "/opt/mtt"
> 
> It looks like EvaluateString does not like the slashes,
> because something silly like this doesn't give me the syntax
> error:
> 
> shell_build_command = &join("configure --with-lib-mpi=", &test_np(), "gmake")
> 
> Note: Below is a patch to give Build.pm visibility of
> test_prefix(), though this will also produce the error:
> 
> &join("configure --with-lib-mpi=", &shell("pwd"), "gmake")
> 
> -Ethan
> 
> 
> Index: MTT/Test/Build.pm
> ===================================================================
> --- MTT/Test/Build.pm (revision 410)
> +++ MTT/Test/Build.pm (working copy)
> @@ -251,6 +251,10 @@
>          }
>      }
>  
> +    # Some test suites require knowledge of where
> +    # the MPI library is at the build stage
> +    $MTT::Test::Run::test_prefix = $mpi_install->{installdir};
> +
>      # Process setenv, unsetenv, prepend-path, and append-path -- for
>      # both the MPI that we're building with and the section of the ini
>      # file that we're building.
> _______________________________________________
> mtt-users mailing list
> mtt-us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-users

Reply via email to