Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[cli] Fix a bug from flow that stopped testing for ambiguous obj exactness#4449

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Brianzchen merged 3 commits intoflow-typed:mainfromBrianzchen:exact-error-post-200
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from2 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
122 changes: 77 additions & 45 deletionscli/src/commands/__tests__/runTests-test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,6 +47,21 @@ describe('run-tests (command)', () => {
const testDir = path.join(TEST_DIR, 'unit-test');
const flowConfigFile = path.join(testDir, '.flowconfig');

const createFlowConfig = async (
version: string,
depPaths?: Array<string> = [],
) => {
await writeFlowConfig(
fixtureBasePath,
testDir,
path.join(fixtureBasePath, 'definitions/npm/def/'),
version,
depPaths,
);

return fs.readFileSync(flowConfigFile, 'utf-8').split('\n');
};

beforeAll(() => {
fs.mkdirSync(testDir, {recursive: true});
});
Expand All@@ -56,17 +71,7 @@ describe('run-tests (command)', () => {
});

it('writes the file correctly', async () => {
await writeFlowConfig(
fixtureBasePath,
testDir,
path.join(fixtureBasePath, 'definitions/npm/def/'),
'0.181.0',
[],
);

const flowConfigSplit = fs
.readFileSync(flowConfigFile, 'utf-8')
.split('\n');
const flowConfigSplit = await createFlowConfig('0.181.0');

const matches = [
'[libs]',
Expand All@@ -93,17 +98,7 @@ describe('run-tests (command)', () => {
});

it('writes flow suppression if flow version is less than 0.125.0', async () => {
await writeFlowConfig(
fixtureBasePath,
testDir,
path.join(fixtureBasePath, 'definitions/npm/def/'),
'0.124.0',
[],
);

const flowConfigSplit = fs
.readFileSync(flowConfigFile, 'utf-8')
.split('\n');
const flowConfigSplit = await createFlowConfig('0.124.0');

const matches = [
'[libs]',
Expand All@@ -129,18 +124,8 @@ describe('run-tests (command)', () => {
});
});

it('does not have inexplicit lint when less than flow version less than 0.104.0', async () => {
await writeFlowConfig(
fixtureBasePath,
testDir,
path.join(fixtureBasePath, 'definitions/npm/def/'),
'0.103.0',
[],
);

const flowConfigSplit = fs
.readFileSync(flowConfigFile, 'utf-8')
.split('\n');
it('does not have inexplicit lint when flow version less than 0.104.0', async () => {
const flowConfigSplit = await createFlowConfig('0.103.0');

const matches = [
'[libs]',
Expand All@@ -166,18 +151,65 @@ describe('run-tests (command)', () => {
});
});

it('writes the dependency definitions correctly', async () => {
await writeFlowConfig(
fixtureBasePath,
testDir,
path.join(fixtureBasePath, 'definitions/npm/def/'),
'0.183.0',
['dep-1', 'dep-2'],
);
it('has inexplicit lint when flow version above 0.104.0 and below 0.201.0', async () => {
const flowConfigSplit = await createFlowConfig('0.200.1');

const flowConfigSplit = fs
.readFileSync(flowConfigFile, 'utf-8')
.split('\n');
const matches = [
'[libs]',
'def',
/.*cli\/src\/commands\/__tests__\/__util__\/tdd_framework\.js$/,
'',
'[options]',
'include_warnings=true',
'server.max_workers=0',
'',
'sharedmemory.heap_size=3221225472',
'',
'',
'[ignore]',
/.*\/cli\/node_modules$/,
'',
'[lints]',
'implicit-inexact-object=error',
];

matches.forEach((match, i) => {
expect(flowConfigSplit[i]).toMatch(match);
});
});

it('has ambiguous obj instead of inexplicit lint beyond expected version', async () => {
const flowConfigSplit = await createFlowConfig('0.201.0');

const matches = [
'[libs]',
'def',
/.*cli\/src\/commands\/__tests__\/__util__\/tdd_framework\.js$/,
'',
'[options]',
'include_warnings=true',
'server.max_workers=0',
'',
'sharedmemory.heap_size=3221225472',
'',
'',
'[ignore]',
/.*\/cli\/node_modules$/,
'',
'[lints]',
'ambiguous-object-type=error',
];

matches.forEach((match, i) => {
expect(flowConfigSplit[i]).toMatch(match);
});
});

it('writes the dependency definitions correctly', async () => {
const flowConfigSplit = await createFlowConfig('0.183.0', [
'dep-1',
'dep-2',
]);

const matches = [
'[libs]',
Expand Down
5 changes: 4 additions & 1 deletioncli/src/commands/runTests.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -412,7 +412,10 @@ export async function writeFlowConfig(
path.join(testDirPath, '..', '..', 'node_modules'),
'',
'[lints]',
semver.gte(version, '0.104.0') ? 'implicit-inexact-object=error' : '',
semver.gte(version, '0.104.0') && semver.lt(version, '0.201.0')
? 'implicit-inexact-object=error'
: '',
semver.gte(version, '0.201.0') ? 'ambiguous-object-type=error' : '',
].join('\n');
await fs.writeFile(destFlowConfigPath, flowConfigData);
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp