211 fun with_overlord_dir name f = |
211 fun with_overlord_dir name f = |
212 (Path.explode "$ISABELLE_HOME_USER" + Path.basic (name ^ serial_string ())) |
212 (Path.explode "$ISABELLE_HOME_USER" + Path.basic (name ^ serial_string ())) |
213 |> Isabelle_System.make_directory |
213 |> Isabelle_System.make_directory |
214 |> Exn.capture f |
214 |> Exn.capture f |
215 |> Exn.release |
215 |> Exn.release |
216 |
|
217 fun elapsed_time description e = |
|
218 let val ({elapsed, ...}, result) = Timing.timing e () |
|
219 in (result, (description, Time.toMilliseconds elapsed)) end |
|
220 |
216 |
221 fun value (contains_existentials, ((genuine_only, (quiet, verbose)), size)) |
217 fun value (contains_existentials, ((genuine_only, (quiet, verbose)), size)) |
222 ctxt cookie (code_modules, _) = |
218 ctxt cookie (code_modules, _) = |
223 let |
219 let |
224 val ((is_genuine, counterexample_of), (get, put, put_ml)) = cookie |
220 val ((is_genuine, counterexample_of), (get, put, put_ml)) = cookie |
263 "exec \"$ISABELLE_GHC\" " ^ Code_Haskell.language_params ^ " " ^ ghc_options ^ " " ^ |
259 "exec \"$ISABELLE_GHC\" " ^ Code_Haskell.language_params ^ " " ^ ghc_options ^ " " ^ |
264 (space_implode " " |
260 (space_implode " " |
265 (map File.bash_platform_path |
261 (map File.bash_platform_path |
266 (map fst includes @ [code_file, narrowing_engine_file, main_file]))) ^ |
262 (map fst includes @ [code_file, narrowing_engine_file, main_file]))) ^ |
267 " -o " ^ File.bash_platform_path executable ^ ";" |
263 " -o " ^ File.bash_platform_path executable ^ ";" |
268 val (_, compilation_time) = |
264 val compilation_time = |
269 elapsed_time "Haskell compilation" (fn () => Isabelle_System.bash cmd) |
265 Isabelle_System.bash_process cmd |
270 val _ = Quickcheck.add_timing compilation_time current_result |
266 |> Process_Result.print |
|
267 |> Process_Result.timing |> #elapsed |> Time.toMilliseconds; |
|
268 val _ = Quickcheck.add_timing ("Haskell compilation", compilation_time) current_result |
271 fun haskell_string_of_bool v = if v then "True" else "False" |
269 fun haskell_string_of_bool v = if v then "True" else "False" |
272 val _ = if Isabelle_System.bash cmd <> 0 then error "Compilation with GHC failed" else () |
270 val _ = if Isabelle_System.bash cmd <> 0 then error "Compilation with GHC failed" else () |
273 fun with_size genuine_only k = |
271 fun with_size genuine_only k = |
274 if k > size then (NONE, !current_result) |
272 if k > size then (NONE, !current_result) |
275 else |
273 else |
276 let |
274 let |
277 val _ = verbose_message ("[Quickcheck-narrowing] Test data size: " ^ string_of_int k) |
275 val _ = verbose_message ("[Quickcheck-narrowing] Test data size: " ^ string_of_int k) |
278 val _ = current_size := k |
276 val _ = current_size := k |
279 val ((response, _), timing) = |
277 val res = |
280 elapsed_time ("execution of size " ^ string_of_int k) |
278 Isabelle_System.bash_process |
281 (fn () => Isabelle_System.bash_output |
279 (File.bash_path executable ^ " " ^ haskell_string_of_bool genuine_only ^ " " ^ |
282 (File.bash_path executable ^ " " ^ haskell_string_of_bool genuine_only ^ " " ^ |
280 string_of_int k); |
283 string_of_int k)) |
281 val _ = warning (Process_Result.err res); |
284 val _ = Quickcheck.add_timing timing current_result |
282 val response = Process_Result.out res; |
|
283 val timing = res |> Process_Result.timing |> #elapsed |> Time.toMilliseconds; |
|
284 val _ = |
|
285 Quickcheck.add_timing |
|
286 ("execution of size " ^ string_of_int k, timing) current_result |
285 in |
287 in |
286 if response = "NONE" then with_size genuine_only (k + 1) |
288 if response = "NONE" then with_size genuine_only (k + 1) |
287 else |
289 else |
288 let |
290 let |
289 val output_value = the_default "NONE" |
291 val output_value = the_default "NONE" |