Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pass absolute paths to custom Builders #68

Closed
wants to merge 2 commits into from

3 participants

@raydiak

Fixes problem where we chdir before calling the builder, and then pass it the path relative to the old (pre-chdir) working directory

@tadzik
Owner

Good catch, but I think I'd rather change $where where it comes from, as it's passed not only to build(), but also to test() install() and all the others. I think it's sane that all of them just get an absolute $where in the first place.

@FROGGS
Collaborator

@raydiak I would suggest that you also pass it around as an IO::Path object instead of a string, so nobody needs to call .path on it again to get the IO::Path.

It would also be nice to add some documentation how Build.pm is meant to work, and that method build is called with an IO::Path object which holds an absolute path to the working directory. (In case there is no such doc yet)

@raydiak

Agreed, I will look at where $where comes from and adjust accordingly some time tomorrow.

I also agree that it ought to be a path instead of a string, but wasn't sure if such a change would have other consequences. For example, are there likely to be modules in the wild already using a custom builder which have $where explicitly typed as Str?

@tadzik
Owner
@raydiak

This is looking a little more involved than I had assumed. If we want paths to be consistently IO::Paths instead of Strs, changes will be required in several places, unless I've missed something obvious. I'd rather do it properly soon than poorly now, but I'm likely to get to it within another day or two.

@FROGGS
Collaborator

I'd think that this is all what is needed (except for the try {} block tadzik mentioned):

diff --git a/lib/Panda.pm b/lib/Panda.pm
index 2cc21ff..07cafc8 100644
--- a/lib/Panda.pm
+++ b/lib/Panda.pm
@@ -9,7 +9,7 @@ use JSON::Tiny;

 sub tmpdir {
     state $i = 0;
-    ".work/{time}_{$i++}"
+    ".work/{time}_{$i++}".path.absolute
 }

 class Panda {
diff --git a/lib/Panda/Common.pm b/lib/Panda/Common.pm
index 092fbf7..43c3f7c 100644
--- a/lib/Panda/Common.pm
+++ b/lib/Panda/Common.pm
@@ -5,9 +5,9 @@ sub dirname ($mod as Str) is export {
     $mod.subst(':', '_', :g);
 }

-sub indir (Str $where, Callable $what) is export {
+sub indir ($where, Callable $what) is export {
     mkpath $where;
-    temp $*CWD = IO::Spec.rel2abs($where);
+    temp $*CWD = $where.path.absolute;
     $what()
 }

Is Math::ThreeD supposed to fail tests?

@raydiak

FROGGS++ has volunteered to take this issue off my hands as tuits are limited on my end atm

@raydiak raydiak closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 18, 2014
  1. @raydiak
Commits on Feb 20, 2014
  1. @raydiak

    Revert "Pass absolute paths to custom Builders"

    raydiak authored
    This reverts commit a708c13.
This page is out of date. Refresh to see the latest.
Showing with 0 additions and 0 deletions.
Something went wrong with that request. Please try again.