Skip to content

Commit bb6d600

Browse files
committed
style: Format test-main.ts with Prettier
1 parent 723801b commit bb6d600

File tree

1 file changed

+105
-105
lines changed

1 file changed

+105
-105
lines changed

packages/pyright-scip/test/test-main.ts

Lines changed: 105 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -130,146 +130,146 @@ const isJest = typeof describe !== 'undefined' && typeof test !== 'undefined';
130130
if (isJest) {
131131
describe('pyproject parsing', () => {
132132
test('parses various pyproject.toml formats', () => {
133-
const testCases = [
134-
{
135-
expected: { name: undefined, version: undefined },
136-
tomlContents: [
137-
``,
138-
`[project]`,
139-
`[tool.poetry]`,
140-
`[tool]
133+
const testCases = [
134+
{
135+
expected: { name: undefined, version: undefined },
136+
tomlContents: [
137+
``,
138+
`[project]`,
139+
`[tool.poetry]`,
140+
`[tool]
141141
poetry = {}`,
142-
`[tool.poetry]
142+
`[tool.poetry]
143143
name = false
144144
version = {}`,
145-
],
146-
},
147-
{
148-
expected: { name: 'abc', version: undefined },
149-
tomlContents: [
150-
`[project]
145+
],
146+
},
147+
{
148+
expected: { name: 'abc', version: undefined },
149+
tomlContents: [
150+
`[project]
151151
name = "abc"`,
152-
`[tool.poetry]
152+
`[tool.poetry]
153153
name = "abc"`,
154-
`[tool]
154+
`[tool]
155155
poetry = { name = "abc" }`,
156-
`[project]
156+
`[project]
157157
name = "abc"
158158
[tool.poetry]
159159
name = "ignored"`,
160-
],
161-
},
162-
{
163-
expected: { name: undefined, version: '16.05' },
164-
tomlContents: [
165-
`[project]
160+
],
161+
},
162+
{
163+
expected: { name: undefined, version: '16.05' },
164+
tomlContents: [
165+
`[project]
166166
version = "16.05"`,
167-
`[tool.poetry]
167+
`[tool.poetry]
168168
version = "16.05"`,
169-
`[tool]
169+
`[tool]
170170
poetry = { version = "16.05" }`,
171-
`[project]
171+
`[project]
172172
version = "16.05"
173173
[tool.poetry]
174174
version = "ignored"`,
175-
],
176-
},
177-
{
178-
expected: { name: 'abc', version: '16.05' },
179-
tomlContents: [
180-
`[project]
175+
],
176+
},
177+
{
178+
expected: { name: 'abc', version: '16.05' },
179+
tomlContents: [
180+
`[project]
181181
name = "abc"
182182
version = "16.05"`,
183-
`[tool.poetry]
183+
`[tool.poetry]
184184
name = "abc"
185185
version = "16.05"`,
186-
`[project]
186+
`[project]
187187
name = "abc"
188188
[tool.poetry]
189189
version = "16.05"`,
190-
`[project]
190+
`[project]
191191
version = "16.05"
192192
[tool.poetry]
193193
name = "abc"`,
194-
`[project]
194+
`[project]
195195
[tool.poetry]
196196
name = "abc"
197197
version = "16.05"`,
198-
],
199-
},
200-
];
201-
202-
for (const testCase of testCases) {
203-
for (const content of testCase.tomlContents) {
204-
const got = Indexer.inferProjectInfo(false, () => content);
205-
const want = testCase.expected;
206-
if (isJest) {
207-
expect(got.name).toBe(want.name);
208-
expect(got.version).toBe(want.version);
209-
} else {
210-
if (got.name !== want.name || got.version !== want.version) {
211-
throw new Error(`name/version mismatch for ${content}`);
198+
],
199+
},
200+
];
201+
202+
for (const testCase of testCases) {
203+
for (const content of testCase.tomlContents) {
204+
const got = Indexer.inferProjectInfo(false, () => content);
205+
const want = testCase.expected;
206+
if (isJest) {
207+
expect(got.name).toBe(want.name);
208+
expect(got.version).toBe(want.version);
209+
} else {
210+
if (got.name !== want.name || got.version !== want.version) {
211+
throw new Error(`name/version mismatch for ${content}`);
212+
}
212213
}
213214
}
214215
}
215-
}
216216
});
217217
});
218218

219219
describe('snapshot tests', () => {
220-
const mode = process.env.UPDATE_SNAPSHOTS ? 'update' : 'check';
221-
const quiet = process.env.VERBOSE !== 'true';
222-
223-
// Get all test directories
224-
let snapshotDirectories = fs.readdirSync(inputDirectory);
225-
226-
// Check for orphaned outputs
227-
if (fs.existsSync(outputDirectory)) {
228-
const outputTests = fs.readdirSync(outputDirectory);
229-
const inputTests = new Set(snapshotDirectories);
230-
231-
for (const outputTest of outputTests) {
232-
if (!inputTests.has(outputTest)) {
233-
if (mode === 'update') {
234-
const orphanedPath = path.join(outputDirectory, outputTest);
235-
fs.rmSync(orphanedPath, { recursive: true, force: true });
236-
console.log(`Delete output folder with no corresponding input folder: ${outputTest}`);
237-
} else {
238-
fail(`Output folder exists but no corresponding input folder found: ${outputTest}`);
220+
const mode = process.env.UPDATE_SNAPSHOTS ? 'update' : 'check';
221+
const quiet = process.env.VERBOSE !== 'true';
222+
223+
// Get all test directories
224+
let snapshotDirectories = fs.readdirSync(inputDirectory);
225+
226+
// Check for orphaned outputs
227+
if (fs.existsSync(outputDirectory)) {
228+
const outputTests = fs.readdirSync(outputDirectory);
229+
const inputTests = new Set(snapshotDirectories);
230+
231+
for (const outputTest of outputTests) {
232+
if (!inputTests.has(outputTest)) {
233+
if (mode === 'update') {
234+
const orphanedPath = path.join(outputDirectory, outputTest);
235+
fs.rmSync(orphanedPath, { recursive: true, force: true });
236+
console.log(`Delete output folder with no corresponding input folder: ${outputTest}`);
237+
} else {
238+
fail(`Output folder exists but no corresponding input folder found: ${outputTest}`);
239+
}
239240
}
240241
}
241242
}
242-
}
243243

244-
// Run test for each snapshot directory
245-
test.each(snapshotDirectories)('snapshot test: %s', (testName) => {
246-
let projectName: string | undefined;
247-
let projectVersion: string | undefined;
244+
// Run test for each snapshot directory
245+
test.each(snapshotDirectories)('snapshot test: %s', (testName) => {
246+
let projectName: string | undefined;
247+
let projectVersion: string | undefined;
248248

249-
// Only set project name/version from packageInfo if test doesn't have its own pyproject.toml
250-
const testProjectRoot = path.join(inputDirectory, testName);
251-
if (!fs.existsSync(path.join(testProjectRoot, 'pyproject.toml'))) {
252-
projectName = packageInfo['default']['name'];
253-
projectVersion = packageInfo['default']['version'];
254-
}
249+
// Only set project name/version from packageInfo if test doesn't have its own pyproject.toml
250+
const testProjectRoot = path.join(inputDirectory, testName);
251+
if (!fs.existsSync(path.join(testProjectRoot, 'pyproject.toml'))) {
252+
projectName = packageInfo['default']['name'];
253+
projectVersion = packageInfo['default']['version'];
254+
}
255255

256-
if (testName in packageInfo['special']) {
257-
projectName = packageInfo['special'][testName]['name'];
258-
projectVersion = packageInfo['special'][testName]['version'];
259-
}
256+
if (testName in packageInfo['special']) {
257+
projectName = packageInfo['special'][testName]['name'];
258+
projectVersion = packageInfo['special'][testName]['version'];
259+
}
260260

261-
processSingleTest(testName, {
262-
mode: mode as 'check' | 'update',
263-
quiet: quiet,
264-
...(projectName && { projectName }),
265-
...(projectVersion && { projectVersion }),
266-
environment: path.join(snapshotRoot, 'testEnv.json'),
267-
output: 'index.scip',
268-
dev: false,
269-
cwd: path.join(inputDirectory, testName),
270-
targetOnly: undefined,
261+
processSingleTest(testName, {
262+
mode: mode as 'check' | 'update',
263+
quiet: quiet,
264+
...(projectName && { projectName }),
265+
...(projectVersion && { projectVersion }),
266+
environment: path.join(snapshotRoot, 'testEnv.json'),
267+
output: 'index.scip',
268+
dev: false,
269+
cwd: path.join(inputDirectory, testName),
270+
targetOnly: undefined,
271+
});
271272
});
272-
});
273273

274274
afterAll(() => {
275275
checkSometimesAssertions();
@@ -280,7 +280,7 @@ version = "16.05"`,
280280
function runStandaloneTests() {
281281
const mode = process.argv.includes('--update') ? 'update' : 'check';
282282
const quiet = !process.argv.includes('--verbose');
283-
283+
284284
// Run pyproject parsing tests
285285
console.log('Running pyproject parsing tests...');
286286
const testCases = [
@@ -301,7 +301,7 @@ version = "16.05"`,
301301
tomlContents: [`[project]\nname = "abc"\nversion = "16.05"`],
302302
},
303303
];
304-
304+
305305
for (const testCase of testCases) {
306306
for (const content of testCase.tomlContents) {
307307
const got = Indexer.inferProjectInfo(false, () => content);
@@ -313,17 +313,17 @@ version = "16.05"`,
313313
}
314314
}
315315
console.log('✓ pyproject parsing tests passed');
316-
316+
317317
// Run snapshot tests
318318
console.log('\nRunning snapshot tests...');
319319
let snapshotDirectories = fs.readdirSync(inputDirectory);
320320
let failed = false;
321-
321+
322322
for (const testName of snapshotDirectories) {
323323
if (!quiet) {
324324
console.log(`--- Running snapshot test: ${testName} ---`);
325325
}
326-
326+
327327
try {
328328
let projectName: string | undefined;
329329
let projectVersion: string | undefined;
@@ -358,14 +358,14 @@ version = "16.05"`,
358358
}
359359
}
360360
}
361-
361+
362362
checkSometimesAssertions();
363-
363+
364364
if (failed) {
365365
process.exit(1);
366366
}
367367
console.log('\n✓ All snapshot tests passed');
368368
}
369-
369+
370370
runStandaloneTests();
371371
}

0 commit comments

Comments
 (0)