Skip to content

Commit 11b2e1d

Browse files
WIP add yarnBerry to test suite
1 parent 47c83cb commit 11b2e1d

File tree

2 files changed

+52
-18
lines changed

2 files changed

+52
-18
lines changed

src/test/cli-options.test.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as assert from 'uvu/assert';
99
import {suite} from 'uvu';
1010
import {rigTest} from './util/rig-test.js';
1111
import {WireitTestRig} from './util/test-rig.js';
12-
import {Options} from '../cli-options.js';
12+
import {Agent, Options} from '../cli-options.js';
1313
import {Result} from '../error.js';
1414

1515
const test = suite<object>();
@@ -39,6 +39,29 @@ async function getOptionsResult(
3939
},
4040
},
4141
});
42+
43+
if (command.startsWith('yarnBerry')) {
44+
await rig.write({
45+
'yarn.lock':
46+
`# This file is generated by running "yarn install" inside your project.
47+
# Manual changes might be lost - proceed with caution!
48+
49+
__metadata:
50+
version: 8
51+
cacheKey: 10c0
52+
53+
"root-workspace-0b6124@workspace:.":
54+
version: 0.0.0-use.local
55+
resolution: "root-workspace-0b6124@workspace:."
56+
languageName: unknown
57+
linkType: soft
58+
`,
59+
});
60+
await rig.write({
61+
'.yarnrc.yml': 'nodeLinker: node-modules'
62+
});
63+
}
64+
4265
env = {...env, WIREIT_DEBUG_LOG_FILE: ''};
4366
assert.equal((await rig.exec(command, {env}).exit).code, 0);
4467
return JSON.parse(await rig.read('options.json')) as Result<Options>;
@@ -67,8 +90,8 @@ async function assertOptions(
6790
});
6891
}
6992

70-
for (const command of ['npm', 'yarn', 'pnpm'] as const) {
71-
const agent = command === 'yarn' ? 'yarnClassic' : command;
93+
for (const command of ['npm', 'yarn', 'pnpm', 'yarnBerry'] as const) {
94+
const agent: Agent = command === 'yarn' ? 'yarnClassic' : command;
7295
// eslint-disable-next-line @typescript-eslint/unbound-method
7396
const skipIfYarn = command === 'yarn' ? test.skip : test;
7497
// eslint-disable-next-line @typescript-eslint/unbound-method

src/test/util/test-rig.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,33 @@ export class WireitTestRig
6464
*/
6565
override async setup() {
6666
await super.setup();
67-
const absWireitBinaryPath = pathlib.resolve(repoRoot, 'bin', 'wireit.js');
68-
const absWireitTempInstallPath = pathlib.resolve(
69-
this.temp,
70-
'node_modules',
71-
'.bin',
72-
'wireit',
67+
68+
Promise.all(
69+
[
70+
['wireit', ['bin', 'wireit.js']] as const,
71+
['yarnBerry', ['third_party', '.yarn', 'releases', 'yarn-4.0.1.cjs']] as const,
72+
].map(
73+
async ([ name, pathParts ]) => {
74+
const binaryPath = pathlib.resolve(repoRoot, ...pathParts);
75+
const tempInstallPath = pathlib.resolve(
76+
this.temp,
77+
'node_modules',
78+
'.bin',
79+
name,
80+
);
81+
82+
if (IS_WINDOWS) {
83+
// Npm install works differently on Windows, since it won't recognize a
84+
// shebang like "#!/usr/bin/env node". Npm instead uses the cmd-shim
85+
// package to generate Windows shell wrappers for each binary, so we do
86+
// that here too.
87+
await cmdShim(binaryPath, tempInstallPath);
88+
} else {
89+
await this.symlink(binaryPath, tempInstallPath, 'file');
90+
}
91+
}
92+
)
7393
);
74-
if (IS_WINDOWS) {
75-
// Npm install works differently on Windows, since it won't recognize a
76-
// shebang like "#!/usr/bin/env node". Npm instead uses the cmd-shim
77-
// package to generate Windows shell wrappers for each binary, so we do
78-
// that here too.
79-
await cmdShim(absWireitBinaryPath, absWireitTempInstallPath);
80-
} else {
81-
await this.symlink(absWireitBinaryPath, absWireitTempInstallPath, 'file');
82-
}
8394
}
8495

8596
/**

0 commit comments

Comments
 (0)