@@ -20,6 +20,8 @@ import {
2020 downloadDependencyCaches ,
2121 CacheHitKind ,
2222 cacheKey ,
23+ getCsharpDependencyDirs ,
24+ getCsharpTempDependencyDir ,
2325} from "./dependency-caching" ;
2426import { Feature } from "./feature-flags" ;
2527import { KnownLanguage } from "./languages" ;
@@ -38,6 +40,28 @@ function makeAbsolutePatterns(tmpDir: string, patterns: string[]): string[] {
3840 return patterns . map ( ( pattern ) => path . join ( tmpDir , pattern ) ) ;
3941}
4042
43+ test ( "getCsharpDependencyDirs - does not include BMN dir if FF is enabled" , async ( t ) => {
44+ await withTmpDir ( async ( tmpDir ) => {
45+ process . env [ "RUNNER_TEMP" ] = tmpDir ;
46+ const codeql = createStubCodeQL ( { } ) ;
47+ const features = createFeatures ( [ ] ) ;
48+
49+ const results = await getCsharpDependencyDirs ( codeql , features ) ;
50+ t . false ( results . includes ( getCsharpTempDependencyDir ( ) ) ) ;
51+ } ) ;
52+ } ) ;
53+
54+ test ( "getCsharpDependencyDirs - includes BMN dir if FF is enabled" , async ( t ) => {
55+ await withTmpDir ( async ( tmpDir ) => {
56+ process . env [ "RUNNER_TEMP" ] = tmpDir ;
57+ const codeql = createStubCodeQL ( { } ) ;
58+ const features = createFeatures ( [ Feature . CsharpCacheBuildModeNone ] ) ;
59+
60+ const results = await getCsharpDependencyDirs ( codeql , features ) ;
61+ t . assert ( results . includes ( getCsharpTempDependencyDir ( ) ) ) ;
62+ } ) ;
63+ } ) ;
64+
4165test ( "makePatternCheck - returns undefined if no patterns match" , async ( t ) => {
4266 await withTmpDir ( async ( tmpDir ) => {
4367 fs . writeFileSync ( path . join ( tmpDir , "test.java" ) , "" ) ;
@@ -387,3 +411,28 @@ test("getFeaturePrefix - non-C# - returns '' if CsharpNewCacheKey is enabled", a
387411 t . deepEqual ( result , "" , `Expected no feature prefix for ${ knownLanguage } ` ) ;
388412 }
389413} ) ;
414+
415+ test ( "getFeaturePrefix - C# - returns prefix if CsharpCacheBuildModeNone is enabled" , async ( t ) => {
416+ const codeql = createStubCodeQL ( { } ) ;
417+ const features = createFeatures ( [ Feature . CsharpCacheBuildModeNone ] ) ;
418+
419+ const result = await getFeaturePrefix ( codeql , features , KnownLanguage . csharp ) ;
420+ t . notDeepEqual ( result , "" ) ;
421+ t . assert ( result . endsWith ( "-" ) ) ;
422+ // Check the length of the prefix, which should correspond to `cacheKeyHashLength` + 1 for the trailing `-`.
423+ t . is ( result . length , cacheKeyHashLength + 1 ) ;
424+ } ) ;
425+
426+ test ( "getFeaturePrefix - non-C# - returns '' if CsharpCacheBuildModeNone is enabled" , async ( t ) => {
427+ const codeql = createStubCodeQL ( { } ) ;
428+ const features = createFeatures ( [ Feature . CsharpCacheBuildModeNone ] ) ;
429+
430+ for ( const knownLanguage of Object . values ( KnownLanguage ) ) {
431+ // Skip C# since we expect a result for it, which is tested in the previous test.
432+ if ( knownLanguage === KnownLanguage . csharp ) {
433+ continue ;
434+ }
435+ const result = await getFeaturePrefix ( codeql , features , knownLanguage ) ;
436+ t . deepEqual ( result , "" , `Expected no feature prefix for ${ knownLanguage } ` ) ;
437+ }
438+ } ) ;
0 commit comments