Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests stability improvements #2362

Merged
merged 11 commits into from
Jan 2, 2017
11 changes: 10 additions & 1 deletion __tests__/commands/_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ export async function run<T, R>(

const reporter = new Reporter({stdout, stderr: stdout});

const dir = path.join(fixturesLoc, name);
let dir = path.join(fixturesLoc, name);
if (!fixturesLoc) {
// if fixture loc is not set create a tmp dir so that we don't copy CWD during test run
dir = path.join(
os.tmpdir(),
`yarn-${path.basename(dir)}-${Math.random()}`,
);
fs.mkdirp(dir);

}
const cwd = path.join(
os.tmpdir(),
`yarn-${path.basename(dir)}-${Math.random()}`,
Expand Down
2 changes: 0 additions & 2 deletions __tests__/commands/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import * as fs from '../../src/util/fs.js';

const path = require('path');

jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;

const runConfig = buildRun.bind(
null,
reporters.ConsoleReporter,
Expand Down
14 changes: 9 additions & 5 deletions __tests__/commands/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {run as buildRun} from './_helpers.js';
import {run as global} from '../../src/cli/commands/global.js';
import * as fs from '../../src/util/fs.js';
import assert from 'assert';
const isCI = require('is-ci');

jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;

Expand Down Expand Up @@ -34,12 +35,15 @@ function getTempGlobalFolder(): string {
return path.join(os.tmpdir(), `yarn-global-${Math.random()}`);
}

test.concurrent('add without flag', (): Promise<void> => {
return runGlobal(['add', 'react-native-cli'], {}, 'add-without-flag', async (config) => {
assert.ok(await fs.exists(path.join(config.globalFolder, 'node_modules', 'react-native-cli')));
assert.ok(await fs.exists(path.join(config.globalFolder, 'node_modules', '.bin', 'react-native')));
// this test has global folder side effects, run it only in CI
if (isCI) {
test.concurrent('add without flag', (): Promise<void> => {
return runGlobal(['add', 'react-native-cli'], {}, 'add-without-flag', async (config) => {
assert.ok(await fs.exists(path.join(config.globalFolder, 'node_modules', 'react-native-cli')));
assert.ok(await fs.exists(path.join(config.globalFolder, 'node_modules', '.bin', 'react-native')));
});
});
});
}

test.concurrent('add with prefix flag', (): Promise<void> => {
const tmpGlobalFolder = getTempGlobalFolder();
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export async function run(
const registry = config.registries[registryName];
const object = rootManifests[registryName].object;

for (const type of constants.DEPENDENCY_TYPES) {
constants.DEPENDENCY_TYPES.forEach((type) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This construct was crashing node on ubuntu on windows.
I know it is not a good idea to patch Yarn because of a very niche environment but I could not find a nicer workaround

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this only happens only on Node 7 on ubuntu on windows.
Probably needs to be reported with Node.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll revert this change and wait for Node to be stable then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely related to nodejs/node#9419

const deps = object[type];
if (deps && deps[name]) {
found = true;
delete deps[name];
}
}
});

const possibleManifestLoc = path.join(config.cwd, registry.folder, name);
if (await fs.exists(possibleManifestLoc)) {
Expand Down