Better testing that RT#63874 being fully fixed by ddcc02d1
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / _Util.pm
index 4afa4c2..358a3aa 100644 (file)
@@ -23,12 +23,6 @@ BEGIN {
 
     UNSTABLE_DOLLARAT => ( "$]" < 5.013002 ) ? 1 : 0,
 
-    DBICTEST => $INC{"DBICTest/Util.pm"} ? 1 : 0,
-
-    # During 5.13 dev cycle HELEMs started to leak on copy
-    # add an escape for these perls ON SMOKERS - a user will still get death
-    PEEPEENESS => ( eval { DBICTest::RunMode->is_smoker } && ( "$]" >= 5.013005 and "$]" <= 5.013006) ),
-
     ( map
       #
       # the "DBIC_" prefix below is crucial - this is what makes CI pick up
@@ -82,6 +76,7 @@ our @EXPORT_OK = qw(
   scope_guard detected_reinvoked_destructor
   is_exception dbic_internal_try
   quote_sub qsub perlstring serialize deep_clone
+  parent_dir mkdir_p
   UNRESOLVABLE_CONDITION
 );
 
@@ -409,6 +404,54 @@ sub modver_gt_or_eq_and_lt ($$$) {
   ) ? 1 : 0;
 }
 
+
+#
+# Why not just use some higher-level module or at least File::Spec here?
+# Because:
+# 1)  This is a *very* rarely used function, and the deptree is large
+#     enough already as it is
+#
+# 2)  (more importantly) Our tooling is utter shit in this area. There
+#     is no comprehensive support for UNC paths in PathTools and there
+#     are also various small bugs in representation across different
+#     path-manipulation CPAN offerings.
+#
+# Since this routine is strictly used for logical path processing (it
+# *must* be able to work with not-yet-existing paths), use this seemingly
+# simple but I *think* complete implementation to feed to other consumers
+#
+# If bugs are ever uncovered in this routine, *YOU ARE URGED TO RESIST*
+# the impulse to bring in an external dependency. During runtime there
+# is exactly one spot that could potentially maybe once in a blue moon
+# use this function. Keep it lean.
+#
+sub parent_dir ($) {
+  ( $_[0] =~ m{  [\/\\]  ( \.{0,2} ) ( [\/\\]* ) \z }x )
+    ? (
+      $_[0]
+        .
+      ( ( length($1) and ! length($2) ) ? '/' : '' )
+        .
+      '../'
+    )
+    : (
+      require File::Spec
+        and
+      File::Spec->catpath (
+        ( File::Spec->splitpath( "$_[0]" ) )[0,1],
+        '/',
+      )
+    )
+  ;
+}
+
+sub mkdir_p ($) {
+  require File::Path;
+  # do not ask for a recent version, use 1.x API calls
+  File::Path::mkpath([ "$_[0]" ]);  # File::Path does not like objects
+}
+
+
 {
   my $list_ctx_ok_stack_marker;