@@ -464,28 +464,59 @@ def test_compiler_toolchain(self):
464464 def test_ccache_compiler (self ):
465465 compiler_action = shlex .split ('ccache g++ main.cpp' )
466466 res = log_parser .determine_compiler (compiler_action ,
467+ "" ,
467468 self .is_compiler_executable_fun )
468469 self .assertEqual (res , 'g++' )
469470
470471 compiler_action = shlex .split ('ccache main.cpp' )
471472 res = log_parser .determine_compiler (
472473 compiler_action ,
474+ "" ,
473475 self .is_compiler_executable_fun_false )
474476 self .assertEqual (res , 'ccache' )
475477
476478 compiler_action = shlex .split ('ccache -Ihello main.cpp' )
477479 res = log_parser .determine_compiler (
478480 compiler_action ,
481+ "" ,
479482 self .is_compiler_executable_fun_false )
480483 self .assertEqual (res , 'ccache' )
481484
482485 compiler_action = shlex .split ('/usr/lib/ccache/g++ -Ihello main.cpp' )
483486 res = log_parser .determine_compiler (
484487 compiler_action ,
488+ "" ,
485489 self .is_compiler_executable_fun_false )
486490 self .assertEqual (res ,
487491 '/usr/lib/ccache/g++' )
488492
493+ def test_relative_compiler_path (self ):
494+ # When the compiler is provided by absolute path, it should be used
495+ # directly.
496+ compiler_action = shlex .split ('/absolute/path/gcc main.c' )
497+ res = log_parser .determine_compiler (compiler_action ,
498+ '/path/to/project' ,
499+ self .is_compiler_executable_fun )
500+ self .assertEqual (res , '/absolute/path/gcc' )
501+
502+ # When the compiler is provided by relative path, it should be relative
503+ # to the directory section.
504+ compiler_action = shlex .split ('../gcc main.c' )
505+ res = log_parser .determine_compiler (compiler_action ,
506+ '/path/to/project' ,
507+ self .is_compiler_executable_fun )
508+ self .assertEqual (res , '/path/to/gcc' )
509+
510+ # When the compiler is relative, but only the compiler name is provided
511+ # then we searh it in the PATH.
512+ # !!!WARNING!!! Probably this is not the official interpretation of
513+ # the compilation database format.
514+ compiler_action = shlex .split ('gcc main.c' )
515+ res = log_parser .determine_compiler (compiler_action ,
516+ '/path/to/project' ,
517+ self .is_compiler_executable_fun )
518+ self .assertEqual (res , 'gcc' )
519+
489520 @unittest .skipUnless (
490521 'clang' in pathlib .Path (shutil .which ('g++' )).resolve ().name ,
491522 "If gcc or g++ is a symlink to clang this test should be "
0 commit comments