mirror of
https://github.com/zhigang1992/yarn.git
synced 2026-06-14 10:19:15 +08:00
**Summary** macOS tests on Travis CI keep timing out and they run very slowly. This patch attempts to solve this by doing the following: - Use ramfs for `__tests__` folder and for `$TMPDIR` for faster file system - Remove unnecessary `brew update` and `brew install yarn` commands - Remove unnecessary `--max-workers` argument since all CI VMs have only 2 cores - Clean up tmp folders per test after they are done - Fix `link/unlink` test's race condition and previous test case reliance - Fix `request-manager` timeout tests to be more reliable and finish in under our normal timeout - Use real timers by default and add necessary `useFakeTimers` calls - Increase heap size for Linux and OS X to 4 GB since OS X builds were crashing due to limited heap space - Removes retries from Travis CI **Test plan** All tests on all platforms should pass and pass in about 20 minutes max.
42 lines
736 B
JavaScript
42 lines
736 B
JavaScript
/* @flow */
|
|
|
|
import BlockingQueue from '../../src/util/blocking-queue.js';
|
|
|
|
test('max concurrency', async function(): Promise<void> {
|
|
jest.useFakeTimers();
|
|
|
|
const queue = new BlockingQueue('test', 5);
|
|
let i = 0;
|
|
let running = 0;
|
|
|
|
function create(): Promise<void> {
|
|
return queue.push(++i + '', (): Promise<void> => {
|
|
running++;
|
|
jest.runAllTimers();
|
|
|
|
if (running > 5) {
|
|
return Promise.reject(new Error('Concurrency is broken'));
|
|
}
|
|
|
|
running--;
|
|
|
|
return Promise.resolve();
|
|
});
|
|
}
|
|
|
|
await Promise.all([
|
|
create(),
|
|
create(),
|
|
create(),
|
|
create(),
|
|
create(),
|
|
create(),
|
|
create(),
|
|
create(),
|
|
create(),
|
|
create(),
|
|
]);
|
|
|
|
jest.useRealTimers();
|
|
});
|