@@ -23,9 +23,6 @@ class CppLibrary
23
23
# @return [ArduinoBackend] The backend support for this library
24
24
attr_reader :backend
25
25
26
- # @return [Array<Pathname>] The set of artifacts created by this class (note: incomplete!)
27
- attr_reader :artifacts
28
-
29
26
# @return [Array<Pathname>] The set of directories that should be excluded from compilation
30
27
attr_reader :exclude_dirs
31
28
@@ -50,7 +47,6 @@ def initialize(friendly_name, backend)
50
47
@name = friendly_name
51
48
@backend = backend
52
49
@info_cache = nil
53
- @artifacts = [ ]
54
50
@last_err = ""
55
51
@last_out = ""
56
52
@last_msg = ""
@@ -491,13 +487,13 @@ def test_args(aux_libraries, ci_gcc_config)
491
487
# @param test_file [Pathname] The path to the file containing the unit tests
492
488
# @param aux_libraries [Array<Pathname>] The external Arduino libraries required by this project
493
489
# @param ci_gcc_config [Hash] The GCC config object
494
- # @return [Pathname] path to the compiled test executable
490
+ # @return [Tempfile] the compiled test executable
495
491
def build_for_test_with_configuration ( test_file , aux_libraries , gcc_binary , ci_gcc_config )
496
492
base = test_file . basename
497
- executable = Pathname . new ( "unittest_#{ base } .bin" ) . expand_path
498
- File . delete ( executable ) if File . exist? ( executable )
493
+ executable = Tempfile . new ( "unittest_#{ base } .bin" )
494
+ executable . close
499
495
arg_sets = [ ]
500
- arg_sets << [ "-std=c++0x" , "-o" , executable . to_s , "-DARDUINO=100" ]
496
+ arg_sets << [ "-std=c++0x" , "-o" , executable . path , "-DARDUINO=100" ]
501
497
if libasan? ( gcc_binary )
502
498
arg_sets << [ # Stuff to help with dynamic memory mishandling
503
499
"-g" , "-O1" ,
@@ -514,17 +510,20 @@ def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_g
514
510
arg_sets << cpp_files_libraries ( full_dependencies ) . map ( &:to_s )
515
511
arg_sets << [ test_file . to_s ]
516
512
args = arg_sets . flatten ( 1 )
517
- return nil unless run_gcc ( gcc_binary , *args )
513
+ unless run_gcc ( gcc_binary , *args )
514
+ executable . unlink
515
+ return nil
516
+ end
518
517
519
- artifacts << executable
520
518
executable
521
519
end
522
520
523
521
# print any found stack dumps
524
- # @param executable [Pathname ] the path to the test file
522
+ # @param executable [Tempfile ] the path to the test file
525
523
def print_stack_dump ( executable )
524
+ path = Pathname . new ( executable . path )
526
525
possible_dumpfiles = [
527
- executable . sub_ext ( "#{ executable . extname } .stackdump" )
526
+ path . sub_ext ( "#{ path . extname } .stackdump" )
528
527
]
529
528
possible_dumpfiles . select ( &:exist? ) . each do |dump |
530
529
puts "========== Stack dump from #{ dump } :"
0 commit comments