Skip to content

Commit 25f8370

Browse files
committed
Try to fix bass tests
1 parent 8781a76 commit 25f8370

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

tests/BinaryCompatibilityTestCase.php

+24-9
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,19 @@ public function testWindowsBinaryCompatibility(Version $version): void
6666
$binary = __DIR__ . '/storage/bass-' . $version->toString() . '.dll';
6767

6868
if (!\is_file($binary)) {
69-
Downloader::download('https://www.un4seen.com/files/bass%s.zip', [
69+
$result = Downloader::download('https://www.un4seen.com/files/bass%s.zip', [
7070
\str_replace('.', '', $version->toString()),
71-
])
72-
->whenExists('x64/bass.dll',
73-
static fn (DownloaderResult $ctx) => $ctx->extract('x64/bass.dll', $binary),
74-
static fn (DownloaderResult $ctx) => $ctx->extract('bass.dll', $binary),
75-
);
71+
]);
72+
73+
// x64 and >= 2.4
74+
if (\PHP_INT_SIZE === 8 && $result->exists('x64/bass.dll')) {
75+
$result->extract('x64/bass.dll', $binary);
76+
// x86 and < 2.4
77+
} elseif (\PHP_INT_SIZE === 4 && $result->exists('bass.dll')) {
78+
$result->extract('bass.dll', $binary);
79+
} else {
80+
$this->markTestSkipped('Incompatible OS bits');
81+
}
7682
}
7783

7884
$this->expectNotToPerformAssertions();
@@ -94,10 +100,19 @@ public function testDarwinBinaryCompatibility(Version $version): void
94100
$binary = __DIR__ . '/storage/libbass-' . $version->toString() . '.dylib';
95101

96102
if (!\is_file($binary)) {
97-
Downloader::download('https://www.un4seen.com/files/bass%s-osx.zip', [
103+
$result = Downloader::download('https://www.un4seen.com/files/bass%s-osx.zip', [
98104
\str_replace('.', '', $version->toString()),
99-
])
100-
->extract('libbass.dylib', $binary);
105+
]);
106+
107+
// x64 and >= 2.4
108+
if (\PHP_INT_SIZE === 8 && \version_compare($version->toString(), '2.4', '>=')) {
109+
$result->extract('libbass.dylib', $binary);
110+
// x86 and < 2.4
111+
} elseif (\PHP_INT_SIZE === 4 && \version_compare($version->toString(), '2.4', '<')) {
112+
$result->extract('libbass.dylib', $binary);
113+
} else {
114+
$this->markTestSkipped('Incompatible OS bits');
115+
}
101116
}
102117

103118
$this->expectNotToPerformAssertions();

tests/BinaryCompatibilityTestCase/DownloaderResult.php

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ public function whenExists(string $file, callable $then = null, callable $otherw
4343
return $this;
4444
}
4545

46+
/**
47+
* @param string $file
48+
* @return bool
49+
*/
50+
public function exists(string $file): bool
51+
{
52+
return isset($this->phar[$file]);
53+
}
54+
4655
/**
4756
* @param string $file
4857
* @param string $target

0 commit comments

Comments
 (0)