Skip to content

Commit

Permalink
🐛 Filled gap in mutex locking for thread safety
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarlesky committed Aug 7, 2024
1 parent e627631 commit fcf7c82
Showing 1 changed file with 48 additions and 10 deletions.
58 changes: 48 additions & 10 deletions lib/ceedling/test_context_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,48 +66,86 @@ def extract_includes(filepath)

# All header includes .h of test file
def lookup_full_header_includes_list(filepath)
return @all_header_includes[form_file_key( filepath )] || []
val = nil
@lock.synchronize do
val = @all_header_includes[form_file_key( filepath )] || []
end
return val
end

# Header includes .h (minus mocks & framework headers) in test file
def lookup_header_includes_list(filepath)
return @header_includes[form_file_key( filepath )] || []
val = nil
@lock.synchronize do
val = @header_includes[form_file_key( filepath )] || []
end
return val
end

# Include paths of test file specified with TEST_INCLUDE_PATH()
def lookup_include_paths_list(filepath)
return @include_paths[form_file_key( filepath )] || []
val = nil
@lock.synchronize do
val = @include_paths[form_file_key( filepath )] || []
end
return val
end

# Source header_includes within test file
def lookup_source_includes_list(filepath)
return @source_includes[form_file_key( filepath )] || []
val = nil
@lock.synchronize do
val = @source_includes[form_file_key( filepath )] || []
end
return val
end

# Source extras via TEST_SOURCE_FILE() within test file
def lookup_build_directive_sources_list(filepath)
return @source_extras[form_file_key( filepath )] || []
val = nil
@lock.synchronize do
val = @source_extras[form_file_key( filepath )] || []
end
return val
end

def lookup_test_cases(filepath)
return @test_runner_details[form_file_key( filepath )][:test_cases] || []
val = nil
@lock.synchronize do
val = @test_runner_details[form_file_key( filepath )][:test_cases] || []
end
return val
end

def lookup_test_runner_generator(filepath)
return @test_runner_details[form_file_key( filepath )][:generator]
val = nil
@lock.synchronize do
val = @test_runner_details[form_file_key( filepath )][:generator]
end
return val
end

# Mocks within test file with no file extension
def lookup_raw_mock_list(filepath)
return @mocks[form_file_key( filepath )] || []
val = nil
@lock.synchronize do
val = @mocks[form_file_key( filepath )] || []
end
return val
end

def lookup_all_include_paths
return @all_include_paths.uniq
val = nil
@lock.synchronize do
val = @all_include_paths.uniq
end
return val
end

def inspect_include_paths
@include_paths.each { |test, paths| yield test, paths }
@lock.synchronize do
@include_paths.each { |test, paths| yield test, paths }
end
end

def ingest_includes(filepath, includes)
Expand Down

0 comments on commit fcf7c82

Please sign in to comment.