From fcf7c821be27e5e2ef4a1cc71701b06bb22e6b00 Mon Sep 17 00:00:00 2001 From: Michael Karlesky Date: Wed, 7 Aug 2024 16:56:35 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Filled=20gap=20in=20mutex=20lock?= =?UTF-8?q?ing=20for=20thread=20safety?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ceedling/test_context_extractor.rb | 58 +++++++++++++++++++++----- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/lib/ceedling/test_context_extractor.rb b/lib/ceedling/test_context_extractor.rb index f18bda4d..59437855 100644 --- a/lib/ceedling/test_context_extractor.rb +++ b/lib/ceedling/test_context_extractor.rb @@ -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)