[svn:parrot] r46132 - trunk/runtime/parrot/library/TAP

fperrad at svn.parrot.org fperrad at svn.parrot.org
Thu Apr 29 12:37:29 UTC 2010


Author: fperrad
Date: Thu Apr 29 12:37:29 2010
New Revision: 46132
URL: https://trac.parrot.org/parrot/changeset/46132

Log:
[TAP] refactor TAP;Harness;Archive with Archive/TAR library

Modified:
   trunk/runtime/parrot/library/TAP/Harness.pir

Modified: trunk/runtime/parrot/library/TAP/Harness.pir
==============================================================================
--- trunk/runtime/parrot/library/TAP/Harness.pir	Thu Apr 29 12:35:34 2010	(r46131)
+++ trunk/runtime/parrot/library/TAP/Harness.pir	Thu Apr 29 12:37:29 2010	(r46132)
@@ -248,7 +248,6 @@
 .namespace ['TAP';'Harness';'Archive']
 
 .sub '' :init :load :anon
-    load_bytecode 'osutils.pbc'
     $P0 = subclass ['TAP';'Harness'], ['TAP';'Harness';'Archive']
     $P0.'add_attribute'('archive_file')
     $P0.'add_attribute'('archive_extra_files')
@@ -296,12 +295,13 @@
 
 .sub 'runtests' :method
     .param pmc files
+    load_bytecode 'Archive/TAR.pbc'
     $P0 = getattribute self, 'archive_file'
     unless null $P0 goto L1
     die "You must provide the name of the archive to create!"
   L1:
-    .local string archive, dir
-    archive = $P0
+    .local string archive_file, dir
+    archive_file = $P0
     dir = tempdir()
     .local pmc env
     env = new 'Env'
@@ -312,35 +312,22 @@
     .local string current_dir, cmd
     current_dir = cwd()
     chdir(dir)
-    $S0 = self.'_mk_meta'(aggregate)
-    spew('meta.yml', $S0)
+    .local pmc archive
+    archive = new ['Archive';'TAR']
+    archive.'add_files'(files :flat)
+    chdir(current_dir)
+    rmtree(dir)
     $P0 = getattribute self, 'archive_extra_files'
     if null $P0 goto L2
-    $P1 = iter $P0
-  L3:
-    unless $P1 goto L2
-    $S2 = shift $P1
-    $S1 = current_dir . '/'
-    $S1 .= $S2
-    cp($S1, $S2)
-    goto L3
+    archive.'add_files'($P0 :flat)
   L2:
-    $S0 = current_dir
-    $I0 = index $S0, ':'
-    unless $I0 == 1 goto L4
-    $S0 = substr $S0, 2         # remove Windows drive
-  L4:
-    cmd = "tar -cf " . $S0
-    cmd .= "/"
-    $I0 = length archive
-    $I0 -= 3
-    $S0 = substr archive, 0, $I0
-    cmd .= $S0
-    cmd .= " *"
-    system(cmd)
-    chdir(current_dir)
-    gzip($S0)
-    rmtree(dir)
+    $S0 = self.'_mk_meta'(aggregate)
+    archive.'add_data'('meta.yml', $S0)
+    $P0 = loadlib 'gziphandle'
+    $P0 = new 'GzipHandle'
+    $P0.'open'(archive_file, 'wb')
+    archive.'write'($P0)
+    $P0.'close'()
     .return (aggregate)
 .end
 


More information about the parrot-commits mailing list