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

Add test for loading perl6.pbc as bytecode #1824

Closed
p6rt opened this issue Jun 10, 2010 · 10 comments
Closed

Add test for loading perl6.pbc as bytecode #1824

p6rt opened this issue Jun 10, 2010 · 10 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 10, 2010

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

Searchable as RT75650$

@p6rt
Copy link
Author

p6rt commented Jun 10, 2010

From jaleto@gmail.com

Howdy,

I have attached a small patch that adds a test for loading perl6.pbc
via load_bytecode in PIR.

It required making t/harness a bit smarter, so that it runs .pir files
with the Parrot that was used during compilation. The Makefile passes
the environment variable PARROT to the call of t/harness, so that it
knows the correct binary to use. If the PARROT environment variable is
not set (such as when run via prove or perl t/harness) it uses
"parrot_config bindir".

Duke

--
Jonathan "Duke" Leto
jonathan@​leto.net
http://leto.net

@p6rt
Copy link
Author

p6rt commented Jun 10, 2010

From jaleto@gmail.com

0001-Add-test-for-loading-perl6.pbc-bytecode.patch
From b45dd1f7b4a896c727500b64a2e17645b30f073b Mon Sep 17 00:00:00 2001
From: Duke Leto <jonathan@leto.net>
Date: Wed, 9 Jun 2010 13:44:41 -0700
Subject: [PATCH] Add test for loading perl6.pbc bytecode

---
 build/Makefile.in      |    2 +-
 t/02-embed/01-load.pir |   29 +++++++++++++++++++++++++++++
 t/harness              |   14 +++++++++++++-
 3 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 t/02-embed/01-load.pir

diff --git a/build/Makefile.in b/build/Makefile.in
index 48eea9b..4424ede 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -395,7 +395,7 @@ test    : coretest
 fulltest: coretest spectest
 
 coretest: Test.pir $(PERL6_EXE)
-	$(PERL) t/harness t/00-parrot t/01-sanity
+	PARROT=$(PARROT) $(PERL) t/harness t/00-parrot t/01-sanity t/02-embed/01-load.pir
 
 # Run the spectests that we know work.
 spectest_regression: spectest
diff --git a/t/02-embed/01-load.pir b/t/02-embed/01-load.pir
new file mode 100644
index 0000000..f851d98
--- /dev/null
+++ b/t/02-embed/01-load.pir
@@ -0,0 +1,29 @@
+=head1 NAME
+
+t/02-embed/01-load.pir - Tests loading of bytecode
+
+=head1 SYNOPSIS
+
+    % perl t/harness t/02-embed/01-load.pir
+
+=head1 DESCRIPTION
+
+Tests the loading of perl6.pbc
+
+=cut
+
+.sub 'main' :main
+    .include 'test_more.pir'
+
+    plan(1)
+
+    test_load()
+.end
+
+.sub test_load
+    lives_ok(<<'CODE',"can load_bytecode perl6.pbc")
+.sub main
+    load_bytecode "perl6.pbc"
+.end
+CODE
+.end
diff --git a/t/harness b/t/harness
index 73cd653..dcd2579 100644
--- a/t/harness
+++ b/t/harness
@@ -68,7 +68,19 @@ if ($archive) {
 
 if (eval "require $tap_harness_class;") {
     my %harness_options = (
-        exec        => ['./perl6'],
+        # We assume that .t files are Perl 6
+        # and run .pir files with Parrot that we were configured with
+        exec => sub {
+            my ( $harness, $test_file ) = @_;
+            my $parrot = $ENV{PARROT};
+            unless ($parrot) {
+                my $bindir = `parrot_config bindir`;
+                chomp $bindir;
+                $parrot = File::Spec->catfile($bindir, 'parrot');
+            }
+            return ['./perl6', $test_file ] if $test_file =~ /[.]t$/;
+            return [ $parrot, $test_file ] if $test_file =~ /[.]pir$/;
+        },
         verbosity   => 0+$Test::Harness::verbose,
         jobs        => $ENV{TEST_JOBS} || $jobs || 1,
         ignore_exit => 1,
-- 
1.7.0.4

@p6rt
Copy link
Author

p6rt commented Jun 11, 2010

From jonathan@leto.net

moritz++ asked me on IRC when TAP​::Harness got the feature of exec being
a code reference. From the Changes file, I found out that it was added
in 3.12 on 2008-06-22 .

@p6rt
Copy link
Author

p6rt commented Jun 11, 2010

From @pmichaud

There are still a number of not-too-old Linux distros that use
Test​::Harness 2.64; I'd like to make sure that Rakudo testing continues
to work with those. So, if the above patch requires Test​::Harness 3.0
or greater, I'll reject it for now.

It seems to me that an easier approach might be to use Perl 6's qx() or
run() builtins and run Parrot directly from a Perl 6 script, rather than
try to get the test harness to understand .pir files.

Pm

@p6rt
Copy link
Author

p6rt commented Jun 11, 2010

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

@p6rt
Copy link
Author

p6rt commented Jun 12, 2010

From jonathan@leto.net

I've made a new patch that does not require TAP​::Harness 3.x, and uses a
Rakudo test with a call to run() to run the Parrot test which loads the
bytecode.

@p6rt
Copy link
Author

p6rt commented Jun 12, 2010

From jonathan@leto.net

0002-Add-test-for-loading-perl6.pbc-bytecode.patch
From 039c18b01b2c12b95de560c5a26bdc7ac9dd7a32 Mon Sep 17 00:00:00 2001
From: Duke Leto <jonathan@leto.net>
Date: Wed, 9 Jun 2010 13:44:41 -0700
Subject: [PATCH] Add test for loading perl6.pbc bytecode

---
 build/Makefile.in      |    2 +-
 t/02-embed/01-load.pir |   29 +++++++++++++++++++++++++++++
 t/02-embed/01-load.t   |    3 +++
 3 files changed, 33 insertions(+), 1 deletions(-)
 create mode 100644 t/02-embed/01-load.pir
 create mode 100644 t/02-embed/01-load.t

diff --git a/build/Makefile.in b/build/Makefile.in
index 48eea9b..62606c0 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -395,7 +395,7 @@ test    : coretest
 fulltest: coretest spectest
 
 coretest: Test.pir $(PERL6_EXE)
-	$(PERL) t/harness t/00-parrot t/01-sanity
+	PARROT=$(PARROT) $(PERL) t/harness t/00-parrot t/01-sanity t/02-embed
 
 # Run the spectests that we know work.
 spectest_regression: spectest
diff --git a/t/02-embed/01-load.pir b/t/02-embed/01-load.pir
new file mode 100644
index 0000000..948ed25
--- /dev/null
+++ b/t/02-embed/01-load.pir
@@ -0,0 +1,29 @@
+=head1 NAME
+
+t/02-embed/01-load.pir - Tests loading of bytecode
+
+=head1 SYNOPSIS
+
+    % parrot t/02-embed/01-load.pir
+
+=head1 DESCRIPTION
+
+Tests the loading of perl6.pbc . This file is used by t/02-embed/01-load.t
+
+=cut
+
+.sub 'main' :main
+    .include 'test_more.pir'
+
+    plan(1)
+
+    test_load()
+.end
+
+.sub test_load
+    lives_ok(<<'CODE',"can load_bytecode perl6.pbc")
+.sub main
+    load_bytecode "perl6.pbc"
+.end
+CODE
+.end
diff --git a/t/02-embed/01-load.t b/t/02-embed/01-load.t
new file mode 100644
index 0000000..709a5f3
--- /dev/null
+++ b/t/02-embed/01-load.t
@@ -0,0 +1,3 @@
+use v6;
+my $parrot = %*ENV{'PARROT'};
+run("$parrot t/02-embed/01-load.pir");
-- 
1.7.0.4

@p6rt
Copy link
Author

p6rt commented Jun 12, 2010

From [Unknown Contact. See original ticket]

I've made a new patch that does not require TAP​::Harness 3.x, and uses a
Rakudo test with a call to run() to run the Parrot test which loads the
bytecode.

@p6rt
Copy link
Author

p6rt commented Jun 12, 2010

From @moritz

Thanks, I've applied your last patch as
8fc1ef57fae03889c38a566dcc8daa4c0dda3250.

@p6rt
Copy link
Author

p6rt commented Jun 12, 2010

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

@p6rt p6rt closed this as completed Jun 12, 2010
@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