@@ -17,7 +17,7 @@ use build_helper::git::get_closest_merge_commit;
1717
1818use crate :: Config ;
1919use crate :: core:: builder:: { Builder , Cargo , Kind , RunConfig , ShouldRun , Step } ;
20- use crate :: core:: config:: { GccCiMode , TargetSelection } ;
20+ use crate :: core:: config:: TargetSelection ;
2121use crate :: utils:: build_stamp:: { BuildStamp , generate_smart_stamp_hash} ;
2222use crate :: utils:: exec:: command;
2323use crate :: utils:: helpers:: { self , t} ;
@@ -93,9 +93,10 @@ pub enum GccBuildStatus {
9393/// Tries to download GCC from CI if it is enabled and GCC artifacts
9494/// are available for the given target.
9595/// Returns a path to the libgccjit.so file.
96+ #[ cfg( not( test) ) ]
9697fn try_download_gcc ( builder : & Builder < ' _ > , target : TargetSelection ) -> Option < PathBuf > {
9798 // Try to download GCC from CI if configured and available
98- if !matches ! ( builder. config. gcc_ci_mode, GccCiMode :: DownloadFromCi ) {
99+ if !matches ! ( builder. config. gcc_ci_mode, crate :: core :: config :: GccCiMode :: DownloadFromCi ) {
99100 return None ;
100101 }
101102 if target != "x86_64-unknown-linux-gnu" {
@@ -114,6 +115,11 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
114115 Some ( root. join ( "libgccjit.so" ) )
115116}
116117
118+ #[ cfg( test) ]
119+ fn try_download_gcc ( _builder : & Builder < ' _ > , _target : TargetSelection ) -> Option < PathBuf > {
120+ None
121+ }
122+
117123/// This returns information about whether GCC should be built or if it's already built.
118124/// It transparently handles downloading GCC from CI if needed.
119125///
@@ -247,11 +253,13 @@ pub fn add_cg_gcc_cargo_flags(cargo: &mut Cargo, gcc: &GccOutput) {
247253}
248254
249255/// The absolute path to the downloaded GCC artifacts.
256+ #[ cfg( not( test) ) ]
250257fn ci_gcc_root ( config : & Config ) -> PathBuf {
251258 config. out . join ( config. build ) . join ( "ci-gcc" )
252259}
253260
254261/// This retrieves the GCC sha we *want* to use, according to git history.
262+ #[ cfg( not( test) ) ]
255263fn detect_gcc_sha ( config : & Config , is_git : bool ) -> String {
256264 let gcc_sha = if is_git {
257265 get_closest_merge_commit (
0 commit comments