@@ -6,7 +6,7 @@ import * as pathUtils from '../../../common/utils/pathUtils';
66import * as workspaceApis from '../../../common/workspace.apis' ;
77
88// Import the function under test
9- import { getAllExtraSearchPaths } from '../../../managers/common/nativePythonFinder' ;
9+ import { getAllExtraSearchPaths , resetWorkspaceSearchPathsErrorFlag } from '../../../managers/common/nativePythonFinder' ;
1010
1111interface MockWorkspaceConfig {
1212 get : sinon . SinonStub ;
@@ -26,6 +26,8 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
2626 let envConfig : MockWorkspaceConfig ;
2727
2828 setup ( ( ) => {
29+ resetWorkspaceSearchPathsErrorFlag ( ) ;
30+
2931 // Mock VS Code workspace APIs
3032 mockGetConfiguration = sinon . stub ( workspaceApis , 'getConfiguration' ) ;
3133 mockGetWorkspaceFolders = sinon . stub ( workspaceApis , 'getWorkspaceFolders' ) ;
@@ -87,6 +89,7 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
8789
8890 teardown ( ( ) => {
8991 sinon . restore ( ) ;
92+ resetWorkspaceSearchPathsErrorFlag ( ) ;
9093 } ) ;
9194
9295 suite ( 'Legacy Path Consolidation Tests' , ( ) => {
@@ -332,6 +335,33 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
332335 ) ;
333336 } ) ;
334337
338+ test ( 'Global workspace setting warning is only logged once across multiple calls' , async ( ) => {
339+ // Mock → Workspace setting incorrectly set at global level
340+ pythonConfig . get . withArgs ( 'venvPath' ) . returns ( undefined ) ;
341+ pythonConfig . get . withArgs ( 'venvFolders' ) . returns ( undefined ) ;
342+ envConfig . inspect . withArgs ( 'globalSearchPaths' ) . returns ( { globalValue : [ ] } ) ;
343+ envConfig . inspect . withArgs ( 'workspaceSearchPaths' ) . returns ( {
344+ globalValue : [ 'should-be-ignored' ] ,
345+ } ) ;
346+
347+ // Run multiple times
348+ await getAllExtraSearchPaths ( ) ;
349+ await getAllExtraSearchPaths ( ) ;
350+ await getAllExtraSearchPaths ( ) ;
351+
352+ // Assert - error should only be logged once, not three times
353+ const matchingCalls = mockTraceError
354+ . getCalls ( )
355+ . filter ( ( call : sinon . SinonSpyCall ) =>
356+ / w o r k s p a c e S e a r c h P a t h s .* g l o b a l .* l e v e l / i. test ( String ( call . args [ 0 ] ) ) ,
357+ ) ;
358+ assert . strictEqual (
359+ matchingCalls . length ,
360+ 1 ,
361+ `Expected exactly 1 warning about workspaceSearchPaths global level, got ${ matchingCalls . length } ` ,
362+ ) ;
363+ } ) ;
364+
335365 test ( 'Configuration read errors return empty arrays' , async ( ) => {
336366 // Mock → Configuration throws errors
337367 pythonConfig . get . withArgs ( 'venvPath' ) . returns ( undefined ) ;
0 commit comments