Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/yarnpkg-libzip/tests/ZipOpenFS.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const ZIP_FILE3 = ppath.join(ZIP_DIR3, `foo.txt`);
export const ZIP_FILE4 = ppath.join(ZIP_DIR4, `foo.txt`);
export const ZIP_FILE5 = ppath.join(ZIP_DIR5, `foo.txt`);

const itSkipWin32 = process.platform !== `win32` ? it : it.skip;

afterEach(() => {
jest.useRealTimers();
});
Expand Down Expand Up @@ -100,7 +102,8 @@ describe(`ZipOpenFS`, () => {
fs.discardAndClose();
});

it(`can read from a zip file that's a symlink`, () => {
// This test does not work on win32 because the checked in symlink is not properly materialized from git.
itSkipWin32(`can read from a zip file that's a symlink`, () => {
const fs = new ZipOpenFS();

expect(fs.readFileSync(ZIP_FILE4, `utf8`)).toEqual(`foo\n`);
Expand Down
26 changes: 15 additions & 11 deletions packages/yarnpkg-shell/tests/shell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const expectResult = async (promise: Promise<any>, {exitCode = 0, stdout = ``, s
return await expect(promise).resolves.toMatchObject({exitCode, stdout, stderr});
};

// Not all windows sku's ship cat on the path. findstr with "^" will match all the test cases here to map stdin to stdout
// Should https://learn.microsoft.com/en-us/windows/core-utils/overview ship by default with windows, this can be removed and replaced with cat
const catTool = isNotWin32 ? `cat` : `findstr "^"`;

const bufferResult = async (command: string, args: Array<string> = [], options: Partial<UserOptions> & {tty?: boolean} = {}): Promise<Result> => {
const stdout = new PassThrough();
const stderr = new PassThrough();
Expand Down Expand Up @@ -778,7 +782,7 @@ describe(`Shell`, () => {
await xfs.writeFilePromise(file, `hello world\n`);

await expectResult(bufferResult(
`cat < "${file}"`,
`${catTool} < "${file}"`,
), {
stdout: `hello world\n`,
});
Expand All @@ -791,7 +795,7 @@ describe(`Shell`, () => {
await xfs.writeFilePromise(file, `hello world\n`);

await expectResult(bufferResult(
`cat 0< "${file}"`,
`${catTool} 0< "${file}"`,
), {
stdout: `hello world\n`,
});
Expand All @@ -807,7 +811,7 @@ describe(`Shell`, () => {
await xfs.writeFilePromise(file2, `hello world\n`);

await expectResult(bufferResult(
`cat < "${file1}" < "${file2}"`,
`${catTool} < "${file1}" < "${file2}"`,
), {
stdout: `foo bar baz\nhello world\n`,
});
Expand All @@ -820,15 +824,15 @@ describe(`Shell`, () => {
await xfs.writeFilePromise(file, `hello world\n`);

await expect(bufferResult(
`cat 1< "${file}"`,
`${catTool} 1< "${file}"`,
)).rejects.toThrowError(`Unsupported file descriptor: "1"`);

await expect(bufferResult(
`cat 2< "${file}"`,
`${catTool} 2< "${file}"`,
)).rejects.toThrowError(`Unsupported file descriptor: "2"`);

await expect(bufferResult(
`cat 3< "${file}"`,
`${catTool} 3< "${file}"`,
)).rejects.toThrowError(`Unsupported file descriptor: "3"`);
});
});
Expand All @@ -837,15 +841,15 @@ describe(`Shell`, () => {
describe(`<<<`, () => {
it(`should support input redirections (string)`, async () => {
await expectResult(bufferResult(
`cat <<< "hello world"`,
`${catTool} <<< "hello world"`,
), {
stdout: `hello world\n`,
});
});

it(`should support input redirections to fd (string)`, async () => {
await expectResult(bufferResult(
`cat 0<<< "hello world"`,
`${catTool} 0<<< "hello world"`,
), {
stdout: `hello world\n`,
});
Expand All @@ -854,15 +858,15 @@ describe(`Shell`, () => {
it(`should throw on input redirections to unsupported file descriptors`, async () => {
await xfs.mktempPromise(async tmpDir => {
await expect(bufferResult(
`cat 1<<< "hello world"`,
`${catTool} 1<<< "hello world"`,
)).rejects.toThrowError(`Unsupported file descriptor: "1"`);

await expect(bufferResult(
`cat 2<<< "hello world"`,
`${catTool} 2<<< "hello world"`,
)).rejects.toThrowError(`Unsupported file descriptor: "2"`);

await expect(bufferResult(
`cat 3<<< "hello world"`,
`${catTool} 3<<< "hello world"`,
)).rejects.toThrowError(`Unsupported file descriptor: "3"`);
});
});
Expand Down
Loading