Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Oct 2, 2024
1 parent 1153548 commit 2e846d2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/pyright-internal/src/tests/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SemanticTokenItem, SemanticTokensWalker } from '../analyzer/semanticTok
import { TypeInlayHintsItemType, TypeInlayHintsWalker } from '../analyzer/typeInlayHintsWalker';
import { Range } from 'vscode-languageserver-types';
import { ServiceProvider } from '../common/serviceProvider';
import { BaselineDiff, BaselineHandler } from '../baseline';

// This is a bit gross, but it's necessary to allow the fallback typeshed
// directory to be located when running within the jest environment. This
Expand All @@ -48,6 +49,7 @@ export interface FileAnalysisResult {
unusedCodes: Diagnostic[];
unreachableCodes: Diagnostic[];
deprecateds: Diagnostic[];
baselineDiff: BaselineDiff<boolean> | undefined;
}

export function resolveSampleFilePath(fileName: string): string {
Expand Down Expand Up @@ -171,6 +173,7 @@ export function getAnalysisResults(
}

const sourceFiles = fileUris.map((filePath) => program.getSourceFile(filePath));
const baseline = new BaselineHandler(program.fileSystem, program.rootPath);
return sourceFiles.map((sourceFile, index) => {
if (sourceFile) {
const diagnostics = sourceFile.getDiagnostics(configOptions) || [];
Expand All @@ -183,6 +186,9 @@ export function getAnalysisResults(
unusedCodes: diagnostics.filter((diag) => diag.category === DiagnosticCategory.UnusedCode),
unreachableCodes: diagnostics.filter((diag) => diag.category === DiagnosticCategory.UnreachableCode),
deprecateds: diagnostics.filter((diag) => diag.category === DiagnosticCategory.Deprecated),
baselineDiff: baseline.write(false, true, [
{ diagnostics, fileUri: sourceFile.getUri(), version: 1, reason: 'analysis' },
]),
};
return analysisResult;
} else {
Expand All @@ -197,6 +203,7 @@ export function getAnalysisResults(
unusedCodes: [],
unreachableCodes: [],
deprecateds: [],
baselineDiff: undefined,
};
return analysisResult;
}
Expand Down Expand Up @@ -265,7 +272,7 @@ export const validateResultsButBased = (allResults: FileAnalysisResult[], expect
assert.strictEqual(allResults.length, 1);
const result = allResults[0];
for (const [diagnosticType] of entries(result)) {
if (diagnosticType === 'fileUri' || diagnosticType === 'parseResults') {
if (diagnosticType === 'fileUri' || diagnosticType === 'parseResults' || diagnosticType === 'baselineDiff') {
continue;
}
const actualResult = result[diagnosticType].map(
Expand Down

0 comments on commit 2e846d2

Please sign in to comment.