@@ -10,7 +10,7 @@ import * as sinon from "sinon";
1010import * as api from "./api-client" ;
1111import { EnvVar } from "./environment" ;
1212import { getRunnerLogger } from "./logging" ;
13- import { getTestEnv , setupTests } from "./testing-utils" ;
13+ import { setupTests } from "./testing-utils" ;
1414import * as util from "./util" ;
1515
1616setupTests ( test ) ;
@@ -532,96 +532,3 @@ test("Failure.orElse returns the default value for a failure result", (t) => {
532532 const result = new util . Failure ( new Error ( "test error" ) ) ;
533533 t . is ( result . orElse ( "default value" ) , "default value" ) ;
534534} ) ;
535-
536- test . serial (
537- "getCachedCodeQlVersion reuses a version persisted by an earlier step" ,
538- async ( t ) => {
539- await util . withTmpDir ( async ( tmpDir : string ) => {
540- const cacheFile = path . join ( tmpDir , "version.json" ) ;
541- fs . writeFileSync (
542- cacheFile ,
543- JSON . stringify ( {
544- cmd : "/path/to/codeql" ,
545- version : { version : "2.20.0" } ,
546- } ) ,
547- "utf8" ,
548- ) ;
549- const env = getTestEnv ( { [ EnvVar . TEMP ] : tmpDir } ) ;
550- t . deepEqual ( util . getCachedCodeQlVersion ( "/path/to/codeql" , env ) , {
551- version : "2.20.0" ,
552- } ) ;
553- } ) ;
554- } ,
555- ) ;
556-
557- test . serial (
558- "getCachedCodeQlVersion ignores a persisted version from a different CLI" ,
559- async ( t ) => {
560- await util . withTmpDir ( async ( tmpDir : string ) => {
561- const cacheFile = path . join ( tmpDir , "version.json" ) ;
562- fs . writeFileSync (
563- cacheFile ,
564- JSON . stringify ( {
565- cmd : "/path/to/other-codeql" ,
566- version : { version : "2.20.0" } ,
567- } ) ,
568- "utf8" ,
569- ) ;
570- const env = getTestEnv ( { [ EnvVar . TEMP ] : tmpDir } ) ;
571- t . is ( util . getCachedCodeQlVersion ( "/path/to/codeql" , env ) , undefined ) ;
572- } ) ;
573- } ,
574- ) ;
575-
576- test . serial (
577- "getCachedCodeQlVersion ignores a malformed persisted value" ,
578- async ( t ) => {
579- await util . withTmpDir ( async ( tmpDir : string ) => {
580- const cacheFile = path . join ( tmpDir , "version.json" ) ;
581- fs . writeFileSync ( cacheFile , "not valid json" , "utf8" ) ;
582- const env = getTestEnv ( { [ EnvVar . TEMP ] : tmpDir } ) ;
583- t . is ( util . getCachedCodeQlVersion ( "/path/to/codeql" , env ) , undefined ) ;
584- } ) ;
585- } ,
586- ) ;
587-
588- test . serial (
589- "getCachedCodeQlVersion ignores a persisted value with the wrong structure" ,
590- async ( t ) => {
591- await util . withTmpDir ( async ( tmpDir : string ) => {
592- const cacheFile = path . join ( tmpDir , "version.json" ) ;
593- const env = getTestEnv ( { [ EnvVar . TEMP ] : tmpDir } ) ;
594-
595- const testValues = [
596- { cmd : "/path/to/codeql" } ,
597- { cmd : "/path/to/codeql" , version : { } } ,
598- { cmd : "/path/to/codeql" , version : { version : 2 } } ,
599- { version : { version : "2.20.0" } } ,
600- {
601- cmd : "/path/to/codeql" ,
602- version : { version : "2.20.0" , overlayVersion : "1" } ,
603- } ,
604- {
605- cmd : "/path/to/codeql" ,
606- version : { version : "2.20.0" , features : "nope" } ,
607- } ,
608- ] . map ( ( v ) => JSON . stringify ( v ) ) ;
609-
610- for ( const value of testValues ) {
611- fs . writeFileSync ( cacheFile , value , "utf8" ) ;
612- t . is (
613- util . getCachedCodeQlVersion ( "/path/to/codeql" , env ) ,
614- undefined ,
615- value ,
616- ) ;
617- }
618- } ) ;
619- } ,
620- ) ;
621-
622- test . serial ( "getCachedCodeQlVersion ignores non-existent file" , async ( t ) => {
623- await util . withTmpDir ( async ( tmpDir : string ) => {
624- const env = getTestEnv ( { [ EnvVar . TEMP ] : tmpDir } ) ;
625- t . is ( util . getCachedCodeQlVersion ( "/path/to/codeql" , env ) , undefined ) ;
626- } ) ;
627- } ) ;
0 commit comments