respect "prefix" field
This commit is contained in:
parent
a53821415f
commit
2c9bbf78eb
|
|
@ -16,6 +16,7 @@
|
|||
import fs from 'fs';
|
||||
import { Writable, once } from 'stream';
|
||||
import assert from 'assert';
|
||||
import { join } from 'path';
|
||||
|
||||
enum TarType {
|
||||
REGTYPE,
|
||||
|
|
@ -36,6 +37,7 @@ class TarEntry {
|
|||
linkname: string;
|
||||
uid: number;
|
||||
gid: number;
|
||||
prefix: string;
|
||||
|
||||
fileStream: fs.WriteStream | null = null;
|
||||
remainingBytes = 0;
|
||||
|
|
@ -53,10 +55,11 @@ class TarEntry {
|
|||
|
||||
this.uid = parseInt(header.toString('ascii', 108, 116).trim(), 8);
|
||||
this.gid = parseInt(header.toString('ascii', 116, 124).trim(), 8);
|
||||
this.prefix = header.toString('utf8', 345, 500).replace(/\0/g, '');
|
||||
}
|
||||
|
||||
async writeToDisk(outputPath: (path: string) => string) {
|
||||
const fullPath = outputPath(this.name);
|
||||
const fullPath = outputPath(this.prefix ? join(this.prefix, this.name) : this.name);
|
||||
switch (this.type) {
|
||||
case TarType.DIRTYPE:
|
||||
await fs.promises.mkdir(fullPath, { recursive: true, mode: 0o755 });
|
||||
|
|
|
|||
|
|
@ -36,10 +36,11 @@ test('tar extractor', async () => {
|
|||
expect(await readFile(test.info().outputPath('tar-example/symlink'), { encoding: 'utf-8' })).toEqual('foo-content');
|
||||
});
|
||||
|
||||
test('extract browser', async () => {
|
||||
// not run by default because it's not hermetic. i'll remove this once we use the TAR extractor in our code.
|
||||
test.describe('browser downloads', () => {
|
||||
// not run by default because they're not hermetic. i'll remove them once we use the TAR extractor in our code.
|
||||
test.skip(process.env.TEST_TAR_BROWSER !== '1');
|
||||
|
||||
test('chromium-headless-shell', async () => {
|
||||
const response = await fetch('https://playwright.azureedge.net/download-for-internal-testing/playwright/builds/chromium/1152/chromium-headless-shell-linux-arm64.tar.br');
|
||||
const input = Readable.fromWeb(response.body as any);
|
||||
const decompressor = createBrotliDecompress();
|
||||
|
|
@ -118,3 +119,24 @@ test('extract browser', async () => {
|
|||
'manifest.json',
|
||||
]);
|
||||
});
|
||||
|
||||
test('chromium-mac-arm64', async () => {
|
||||
const response = await fetch('https://playwright.azureedge.net/download-for-internal-testing/playwright/builds/chromium/1152/chromium-mac-arm64.tar.br');
|
||||
const input = Readable.fromWeb(response.body as any);
|
||||
const decompressor = createBrotliDecompress();
|
||||
const extractor = new TarExtractor(name => test.info().outputPath(name));
|
||||
await finished(input.pipe(decompressor).pipe(extractor));
|
||||
|
||||
|
||||
expect(await readdir(test.info().outputPath('chrome-mac'))).toEqual(['Chromium.app']);
|
||||
expect(await readdir(test.info().outputPath('chrome-mac/Chromium.app'))).toEqual(['Contents']);
|
||||
expect(await readdir(test.info().outputPath('chrome-mac/Chromium.app/Contents'))).toEqual([
|
||||
'Frameworks',
|
||||
'Info.plist',
|
||||
'MacOS',
|
||||
'PkgInfo',
|
||||
'Resources',
|
||||
]);
|
||||
expect(await readFile(test.info().outputPath('chrome-mac/Chromium.app/Contents/Info.plist'), { encoding: 'utf-8' })).toHaveLength(10903);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue