From: Nicholas Clark Date: Mon, 5 Feb 2007 00:12:25 +0000 (+0000) Subject: Enhance t/lib/common.pl to provide conditional TODOs using eval'd code. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e5f66904ddccdd9e814465548284a85b68fdec8;p=p5sagit%2Fp5-mst-13.2.git Enhance t/lib/common.pl to provide conditional TODOs using eval'd code. p4raw-id: //depot/perl@30123 --- diff --git a/t/lib/common.pl b/t/lib/common.pl index 9deacbc..e4c1463 100644 --- a/t/lib/common.pl +++ b/t/lib/common.pl @@ -73,7 +73,16 @@ for (@prgs){ my($prog,$expected) = split(/\nEXPECT(?:\n|$)/, $_, 2); my ($todo, $todo_reason); - $todo = $prog =~ s/^#\s*TODO(.*)\n//m and $todo_reason = $1; + $todo = $prog =~ s/^#\s*TODO\s*(.*)\n//m and $todo_reason = $1; + # If the TODO reason starts ? then it's taken as a code snippet to evaluate + # This provides the flexibility to have conditional TODOs + if ($todo_reason =~ s/^\?//) { + my $temp = eval $todo_reason; + if ($@) { + die "# In TODO code reason:\n# $todo_reason\n$@"; + } + $todo_reason = $temp; + } if ( $prog =~ /--FILE--/) { my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ; shift @files ;