@@ -17,7 +17,7 @@ use build_helper::git::get_closest_merge_commit;
17
17
18
18
use crate :: Config ;
19
19
use crate :: core:: builder:: { Builder , Cargo , Kind , RunConfig , ShouldRun , Step } ;
20
- use crate :: core:: config:: { GccCiMode , TargetSelection } ;
20
+ use crate :: core:: config:: TargetSelection ;
21
21
use crate :: utils:: build_stamp:: { BuildStamp , generate_smart_stamp_hash} ;
22
22
use crate :: utils:: exec:: command;
23
23
use crate :: utils:: helpers:: { self , t} ;
@@ -93,9 +93,10 @@ pub enum GccBuildStatus {
93
93
/// Tries to download GCC from CI if it is enabled and GCC artifacts
94
94
/// are available for the given target.
95
95
/// Returns a path to the libgccjit.so file.
96
+ #[ cfg( not( test) ) ]
96
97
fn try_download_gcc ( builder : & Builder < ' _ > , target : TargetSelection ) -> Option < PathBuf > {
97
98
// 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 ) {
99
100
return None ;
100
101
}
101
102
if target != "x86_64-unknown-linux-gnu" {
@@ -114,6 +115,11 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
114
115
Some ( root. join ( "libgccjit.so" ) )
115
116
}
116
117
118
+ #[ cfg( test) ]
119
+ fn try_download_gcc ( _builder : & Builder < ' _ > , _target : TargetSelection ) -> Option < PathBuf > {
120
+ None
121
+ }
122
+
117
123
/// This returns information about whether GCC should be built or if it's already built.
118
124
/// It transparently handles downloading GCC from CI if needed.
119
125
///
@@ -247,11 +253,13 @@ pub fn add_cg_gcc_cargo_flags(cargo: &mut Cargo, gcc: &GccOutput) {
247
253
}
248
254
249
255
/// The absolute path to the downloaded GCC artifacts.
256
+ #[ cfg( not( test) ) ]
250
257
fn ci_gcc_root ( config : & Config ) -> PathBuf {
251
258
config. out . join ( config. build ) . join ( "ci-gcc" )
252
259
}
253
260
254
261
/// This retrieves the GCC sha we *want* to use, according to git history.
262
+ #[ cfg( not( test) ) ]
255
263
fn detect_gcc_sha ( config : & Config , is_git : bool ) -> String {
256
264
let gcc_sha = if is_git {
257
265
get_closest_merge_commit (
0 commit comments