From 8e5f66904ddccdd9e814465548284a85b68fdec8 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 5 Feb 2007 00:12:25 +0000 Subject: [PATCH] Enhance t/lib/common.pl to provide conditional TODOs using eval'd code. p4raw-id: //depot/perl@30123 --- t/lib/common.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 ; -- 2.7.4