Testing CPU Core Detection Implementation in Parcel Bundler
This test suite focuses on validating CPU core detection functionality in the Parcel bundler. It ensures accurate counting of processor cores across different operating systems and verifies the reliability of core detection methods.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
parcel-bundler/parcel
packages/core/workers/test/cpuCount.test.js
import assert from 'assert';
import os from 'os';
import getCores, {detectRealCores} from '../src/cpuCount';
describe('cpuCount', function () {
it('Should be able to detect real cpu count', () => {
// Windows not supported as getting the cpu count takes a couple seconds...
if (os.platform() === 'win32') return;
let cores = detectRealCores();
assert(cores > 0);
});
it('getCores should return more than 0', () => {
let cores = getCores(true);
assert(cores > 0);
});
});