@@ -81,6 +81,35 @@ test_that("quickr_prefer_flang respects quickr.fortran_compiler", {
8181 expect_false(quickr ::: quickr_prefer_flang(sysname = " Darwin" ))
8282})
8383
84+ test_that(" quickr_default_fortran_makevars_lines relaxes gfortran cost model" , {
85+ expect_equal(
86+ quickr ::: quickr_default_fortran_makevars_lines(
87+ config_value = function (name ) {
88+ if (identical(name , " FC" )) " gfortran -m64" else " "
89+ }
90+ ),
91+ " PKG_FFLAGS += -fvect-cost-model=cheap"
92+ )
93+
94+ expect_equal(
95+ quickr ::: quickr_default_fortran_makevars_lines(
96+ config_value = function (name ) {
97+ if (identical(name , " FC" )) " /usr/bin/gfortran-13" else " "
98+ }
99+ ),
100+ " PKG_FFLAGS += -fvect-cost-model=cheap"
101+ )
102+
103+ expect_identical(
104+ quickr ::: quickr_default_fortran_makevars_lines(
105+ config_value = function (name ) {
106+ if (identical(name , " FC" )) " flang-new" else " "
107+ }
108+ ),
109+ character ()
110+ )
111+ })
112+
84113test_that(" quickr_fortran_compiler_option validates values" , {
85114 withr :: local_options(quickr.fortran_compiler = " auto" )
86115 expect_null(quickr ::: quickr_fortran_compiler_option())
@@ -130,6 +159,28 @@ test_that("quickr_fcompiler_env writes Makevars when flang is usable", {
130159 expect_true(file.exists(sub(" R_MAKEVARS_USER=" , " " , env , fixed = TRUE )))
131160})
132161
162+ test_that(" quickr_fcompiler_env writes Makevars for default gfortran flags" , {
163+ build_dir <- withr :: local_tempdir()
164+
165+ withr :: local_options(quickr.fortran_compiler = " gfortran" )
166+ env <- quickr ::: quickr_fcompiler_env(
167+ build_dir = build_dir ,
168+ which = function (cmd ) " " ,
169+ system2 = function (... ) " " ,
170+ sysname = " Linux" ,
171+ config_value = function (name ) {
172+ if (identical(name , " FC" )) " gfortran -m64" else " "
173+ }
174+ )
175+
176+ expect_true(startsWith(env , " R_MAKEVARS_USER=" ))
177+ makevars_path <- sub(" ^R_MAKEVARS_USER=" , " " , env )
178+ expect_equal(
179+ readLines(makevars_path ),
180+ " PKG_FFLAGS += -fvect-cost-model=cheap"
181+ )
182+ })
183+
133184test_that(" quickr_fcompiler_env errors when flang is explicitly requested but unavailable" , {
134185 build_dir <- withr :: local_tempdir()
135186
@@ -286,7 +337,8 @@ test_that("quickr_fcompiler_env handles flang unavailable for non-explicit reque
286337 build_dir = build_dir ,
287338 which = function (x ) " " ,
288339 system2 = function (... ) " " ,
289- sysname = " Darwin"
340+ sysname = " Darwin" ,
341+ config_value = function (name ) if (identical(name , " FC" )) " clang" else " "
290342 )
291343 expect_identical(result , character ())
292344})
@@ -341,7 +393,8 @@ test_that("quickr_fcompiler_env falls back when flang runtime not found non-expl
341393 build_dir = build_dir ,
342394 which = function (x ) if (x == " flang-new" ) flang else " " ,
343395 system2 = function (... ) " " ,
344- sysname = " Darwin"
396+ sysname = " Darwin" ,
397+ config_value = function (name ) if (identical(name , " FC" )) " clang" else " "
345398 )
346399 # Should fall back to character() since runtime not found and not explicit
347400 expect_identical(result , character ())
0 commit comments