33 */
44
55import { describe , it , expect , beforeAll , afterAll , afterEach , vi } from 'vitest' ;
6- import { mkdirSync , writeFileSync , rmSync , chmodSync } from 'fs' ;
6+ import { writeFileSync , rmSync , chmodSync } from 'fs' ;
77import { execFileSync } from 'child_process' ;
88import { join } from 'path' ;
9+ import { createProjectTempDir } from '../../../src/utils/temp-dir' ;
910import {
1011 buildCodeQLArgs ,
1112 buildQLTArgs ,
@@ -603,17 +604,16 @@ describe('resolveCodeQLBinary', () => {
603604 expect ( getResolvedCodeQLDir ( ) ) . toBeNull ( ) ;
604605 } ) ;
605606
606- it ( 'should return the full path and set dir to parent directory' , ( ) => {
607+ it ( 'should return bare codeql command and set dir to parent directory' , ( ) => {
607608 // Create a temporary file named "codeql" to pass validation
608- const tmpDir = join ( process . cwd ( ) , '.tmp' , ' codeql-path-test') ;
609+ const tmpDir = createProjectTempDir ( ' codeql-path-test- ') ;
609610 const codeqlPath = join ( tmpDir , 'codeql' ) ;
610- mkdirSync ( tmpDir , { recursive : true } ) ;
611611 writeFileSync ( codeqlPath , '#!/bin/sh\necho test' , { mode : 0o755 } ) ;
612612
613613 try {
614614 process . env . CODEQL_PATH = codeqlPath ;
615615 const result = resolveCodeQLBinary ( ) ;
616- expect ( result ) . toBe ( codeqlPath ) ;
616+ expect ( result ) . toBe ( 'codeql' ) ;
617617 expect ( getResolvedCodeQLDir ( ) ) . toBe ( tmpDir ) ;
618618 } finally {
619619 rmSync ( tmpDir , { recursive : true , force : true } ) ;
@@ -696,9 +696,8 @@ describe('CODEQL_PATH - PATH prepend integration', () => {
696696
697697 it ( 'should prepend CODEQL_PATH directory to child process PATH' , async ( ) => {
698698 // Create a temporary directory with a fake "codeql" script
699- const tmpDir = join ( process . cwd ( ) , '.tmp' , ' codeql-path-prepend-test') ;
699+ const tmpDir = createProjectTempDir ( ' codeql-path-prepend-test- ') ;
700700 const codeqlPath = join ( tmpDir , 'codeql' ) ;
701- mkdirSync ( tmpDir , { recursive : true } ) ;
702701 writeFileSync ( codeqlPath , '#!/bin/sh\necho test' , { mode : 0o755 } ) ;
703702 chmodSync ( codeqlPath , 0o755 ) ;
704703
@@ -755,9 +754,8 @@ describe('validateCodeQLBinaryReachable', () => {
755754
756755 it ( 'should throw a descriptive error when codeql is not reachable' , async ( ) => {
757756 // Create a temporary directory with a fake "codeql" that exits with error
758- const tmpDir = join ( process . cwd ( ) , '.tmp' , ' codeql-unreachable-test') ;
757+ const tmpDir = createProjectTempDir ( ' codeql-unreachable-test- ') ;
759758 const codeqlPath = join ( tmpDir , 'codeql' ) ;
760- mkdirSync ( tmpDir , { recursive : true } ) ;
761759 // Create a script that fails immediately
762760 writeFileSync ( codeqlPath , '#!/bin/sh\nexit 1' , { mode : 0o755 } ) ;
763761 chmodSync ( codeqlPath , 0o755 ) ;
@@ -773,9 +771,8 @@ describe('validateCodeQLBinaryReachable', () => {
773771 } ) ;
774772
775773 it ( 'should include guidance about CODEQL_PATH in error message' , async ( ) => {
776- const tmpDir = join ( process . cwd ( ) , '.tmp' , ' codeql-guidance-test') ;
774+ const tmpDir = createProjectTempDir ( ' codeql-guidance-test- ') ;
777775 const codeqlPath = join ( tmpDir , 'codeql' ) ;
778- mkdirSync ( tmpDir , { recursive : true } ) ;
779776 writeFileSync ( codeqlPath , '#!/bin/sh\nexit 1' , { mode : 0o755 } ) ;
780777 chmodSync ( codeqlPath , 0o755 ) ;
781778
0 commit comments