Skip to content

Commit

Permalink
Simplify cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 9, 2023
1 parent e692e2c commit aad6b5a
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use xp\lambda\{PackageLambda, Sources};

class PackagingTest {
private $archives= [], $cleanup= [];
private $cleanup= [];

/** Creates a new temporary folder */
private function tempDir(): Folder {
Expand Down Expand Up @@ -69,15 +69,11 @@ private function package(Sources $sources): ZipIterator {
}

// Remember to close the archive
$this->archives[]= $zip= ZipFile::open($target);
return $zip->iterator();
return ZipFile::open($target)->iterator();
}

#[After]
private function cleanup() {
foreach ($this->files as $file) {
$file->close();
}
foreach ($this->cleanup as $folder) {
$this->removeDir($folder);
}
Expand Down Expand Up @@ -127,7 +123,7 @@ public function test_sources_ignored($test) {
$path= $this->create([
'src' => [Sources::IS_FOLDER, 0755],
$test => [Sources::IS_FOLDER, 0755],
$test.'/t.sh' => [Sources::IS_FILE, 'Test'],
$test.'/t.sh' => [Sources::IS_FILE, '#!/bin/sh ...'],
'src/file.txt' => [Sources::IS_FILE, 'Test']
]);
$zip= $this->package(new Sources($path, ['src']));
Expand Down

0 comments on commit aad6b5a

Please sign in to comment.