Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance t/harness (again) #112

Closed
p6rt opened this issue May 28, 2008 · 8 comments
Closed

enhance t/harness (again) #112

p6rt opened this issue May 28, 2008 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 28, 2008

Migrated from rt.perl.org#54988 (status was 'resolved')

Searchable as RT54988$

@p6rt
Copy link
Author

p6rt commented May 28, 2008

From @moritz

Attached patch enhances t/harness, this time it offers the possibility
to call fudge on a per-file base (as requested on IRC by particle and
pmichaud, iirc).

The patch adds a --configfudge option, which (in conjunction with
--tests-from-file ) only fudges those tests which are marked with
'#fudge' at the end.

Copy the attaced configfudge.data to languages/perl6/t, cd to
languages/perl6 and then run

perl t/harness --configfudge --tests-from-file=t/configfudge.data
--keep-exit-code

for a small demonstration.

Without --configfudge the behaviour is unchanged.
Please test this on Windows and MacOS, I have no access to such systems.

If you think the implemented behaviour makes sense I'll add a bit of
documentation.

Cheers,
Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented May 28, 2008

From @moritz

harnes_refactor2.patch
Index: languages/perl6/t/harness
===================================================================
--- languages/perl6/t/harness	(revision 27887)
+++ languages/perl6/t/harness	(working copy)
@@ -22,6 +22,7 @@
 GetOptions(
         'tests-from-file=s' => \my $list_file,
         'fudge'             => \my $do_fudge,
+        'configfudge'         => \my $configfudge,
     );
 
 
@@ -29,7 +30,7 @@
 my @files = grep m/^[^-]/, @ARGV;
 
 my %accepted_tests;
-if ($list_file) {
+if ($list_file || $configfudge) {
     open(my $f, '<', $list_file) 
         or die "Can't ope file '$list_file' for reading: $!";
     my $slash = $^O eq 'MSWin32' ? '\\' : '/';
@@ -37,33 +38,58 @@
         next if m/^\s*#/;
         next unless m/\S/;
         chomp;
-        $_ =~ s/\//$slash/g;
-        $accepted_tests{"t${slash}spec${slash}$_"} = 1;
+        my ($fn, $fudgespec) = split m/\s+#/;
+        $fn = "t/spec/$fn";
+        $fn =~ s/\//$slash/g;
+        $accepted_tests{$fn} = $fudgespec;
     }
     close $f;
 }
 
-if (defined($do_fudge) || $list_file ){
-    my $impl   = 'rakudo';
-    my @tfiles = sort map { -d $_ ? all_in($_) : $_ } map glob, @files;
-    if ($list_file){
-        @tfiles = grep { $accepted_tests{$_} } @tfiles;
-        die "No tests to run!" unless @tfiles;
-    }
+# first prepare our list of files
+my @tfiles;
+if ($list_file){
+    @tfiles = map { all_in($_) } sort keys %accepted_tests;
+} else {
+    @tfiles = map { all_in($_) } sort @files;
+}
+
+# then decide if and what to fudge
+if (defined($do_fudge) || defined($configfudge)){
     if ($do_fudge){
-        my $cmd = join ' ', $^X, 't/spec/fudgeall', @pass_through_options, $impl, @tfiles;
-        print "$cmd\n";
-        $harness_args{arguments} = [ split ' ', `$cmd` ];
+        @tfiles = fudge(@tfiles);
     } else {
-        $harness_args{arguments} = \@tfiles;
+        my (@fudge, @nofudge);
+        for (@tfiles){
+            if ($accepted_tests{$_} eq 'fudge'){
+                push @fudge, $_;
+            } else {
+                push @nofudge, $_;
+            }
+        }
+        if (@fudge) {
+            @tfiles = sort @nofudge, fudge(@fudge);
+        }
     }
 }
 
+$harness_args{arguments} = \@tfiles;
+
+sub fudge {
+    my $impl   = 'rakudo';
+    my $cmd = join ' ', $^X, 't/spec/fudgeall', 
+                        @pass_through_options, $impl, @_;
+    print "$cmd\n";
+    return split ' ', `$cmd`;
+}
+
 # Stolen directly from 'prove'
 # adapted to return only files ending in '.t'
 sub all_in {
     my $start = shift;
 
+    return $start unless -d $start;
+
     my @hits = ();
 
     local *DH;
@@ -94,4 +120,3 @@
 
 eval 'use Parrot::Test::Harness %harness_args';
 
-

@p6rt
Copy link
Author

p6rt commented May 28, 2008

From @moritz

# this is a list of all spec tests that are supposed to pass
# on current rakudo.
# empty lines and those beginning with a # are ignored

S02-builtin_data_types/type.t #fudge
S02-literals/autoref.t #fudge
S03-operators/not.t
S03-operators/autoincrement.t
S04-statements/until.t
S04-statements/while.t #fudge

@p6rt
Copy link
Author

p6rt commented May 28, 2008

From @moritz

perl6 via RT wrote​:

Attached patch enhances t/harness, this time it offers the possibility
to call fudge on a per-file base (as requested on IRC by particle and
pmichaud, iirc).

The patch adds a --configfudge option, which (in conjunction with
--tests-from-file ) only fudges those tests which are marked with
'#fudge' at the end.

The attached patch is a revised version which assumes fudging to be the
default (as discussed with patrick and particle on #parrot). Fudging can
now be disabled with a #pure comment at the end of the line.

The patch also enables that for the new 'localtest' make target.

Cheers,
Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented May 28, 2008

From @moritz

localtest-configfudge.patch
Index: t/harness
===================================================================
--- t/harness	(revision 27895)
+++ t/harness	(working copy)
@@ -22,6 +22,7 @@
 GetOptions(
         'tests-from-file=s' => \my $list_file,
         'fudge'             => \my $do_fudge,
+        'configfudge'         => \my $configfudge,
     );
 
 
@@ -29,7 +30,7 @@
 my @files = grep m/^[^-]/, @ARGV;
 
 my %accepted_tests;
-if ($list_file) {
+if ($list_file || $configfudge) {
     open(my $f, '<', $list_file) 
         or die "Can't ope file '$list_file' for reading: $!";
     my $slash = $^O eq 'MSWin32' ? '\\' : '/';
@@ -37,33 +38,58 @@
         next if m/^\s*#/;
         next unless m/\S/;
         chomp;
-        $_ =~ s/\//$slash/g;
-        $accepted_tests{"t${slash}spec${slash}$_"} = 1;
+        my ($fn, $fudgespec) = split m/\s+#/;
+        $fn = "t/spec/$fn";
+        $fn =~ s/\//$slash/g;
+        $accepted_tests{$fn} = $fudgespec;
     }
     close $f;
 }
 
-if (defined($do_fudge) || $list_file ){
-    my $impl   = 'rakudo';
-    my @tfiles = sort map { -d $_ ? all_in($_) : $_ } map glob, @files;
-    if ($list_file){
-        @tfiles = grep { $accepted_tests{$_} } @tfiles;
-        die "No tests to run!" unless @tfiles;
-    }
+# first prepare our list of files
+my @tfiles;
+if ($list_file){
+    @tfiles = map { all_in($_) } sort keys %accepted_tests;
+} else {
+    @tfiles = map { all_in($_) } sort @files;
+}
+
+# then decide if and what to fudge
+if (defined($do_fudge) || defined($configfudge)){
     if ($do_fudge){
-        my $cmd = join ' ', $^X, 't/spec/fudgeall', @pass_through_options, $impl, @tfiles;
-        print "$cmd\n";
-        $harness_args{arguments} = [ split ' ', `$cmd` ];
+        @tfiles = fudge(@tfiles);
     } else {
-        $harness_args{arguments} = \@tfiles;
+        my (@fudge, @nofudge);
+        for (@tfiles){
+            if ($accepted_tests{$_} =~ m/^(?:pure|raw)$/){
+                push @nofudge, $_;
+            } else {
+                push @fudge, $_;
+            }
+        }
+        if (@fudge) {
+            @tfiles = sort @nofudge, fudge(@fudge);
+        }
     }
 }
 
+$harness_args{arguments} = \@tfiles;
+
+sub fudge {
+    my $impl   = 'rakudo';
+    my $cmd = join ' ', $^X, 't/spec/fudgeall', 
+                        @pass_through_options, $impl, @_;
+    print "$cmd\n";
+    return split ' ', `$cmd`;
+}
+
 # Stolen directly from 'prove'
 # adapted to return only files ending in '.t'
 sub all_in {
     my $start = shift;
 
+    return $start unless -d $start;
+
     my @hits = ();
 
     local *DH;
@@ -94,4 +120,3 @@
 
 eval 'use Parrot::Test::Harness %harness_args';
 
-
Index: config/makefiles/root.in
===================================================================
--- config/makefiles/root.in	(revision 27895)
+++ config/makefiles/root.in	(working copy)
@@ -165,7 +165,7 @@
 
 localtest: t/localtest.data
 	$(PERL) t/harness \
-        --fudge \
+        --configfudge \
         --tests-from-file=t/localtest.data \
         --keep-exit-code \
         t/spec/ \

@p6rt
Copy link
Author

p6rt commented May 29, 2008

From @particle

On Wed, May 28, 2008 at 3​:14 PM, Moritz Lenz
<moritz@​casella.verplant.org> wrote​:

perl6 via RT wrote​:

Attached patch enhances t/harness, this time it offers the possibility
to call fudge on a per-file base (as requested on IRC by particle and
pmichaud, iirc).

The patch adds a --configfudge option, which (in conjunction with
--tests-from-file ) only fudges those tests which are marked with
'#fudge' at the end.

The attached patch is a revised version which assumes fudging to be the
default (as discussed with patrick and particle on #parrot). Fudging can
now be disabled with a #pure comment at the end of the line.

The patch also enables that for the new 'localtest' make target.

thanks, applied with minor modifications as r27897.
~jerry

@p6rt
Copy link
Author

p6rt commented May 29, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 29, 2008

@particle - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed May 29, 2008
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant