From ea51e2b35cb10fad3cbdc101142543daf96ea80f Mon Sep 17 00:00:00 2001 From: Fabian Zahn Date: Thu, 22 Feb 2018 21:21:32 +0100 Subject: [PATCH] Refactored the os specific settings, it is now possible to convert both styles on every system (and even mixed) --- auto/parse_output.rb | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/auto/parse_output.rb b/auto/parse_output.rb index 33d1f71..02adbdc 100644 --- a/auto/parse_output.rb +++ b/auto/parse_output.rb @@ -23,6 +23,7 @@ class ParseOutput @class_name = 0 @test_suite = nil @total_tests = false + @path_delim = nil end # Set the flag to indicate if there will be an XML output file or not @@ -45,11 +46,7 @@ class ParseOutput def test_suite_verify(test_suite_name) # Split the path name - test_name = if @class_name == 1 - test_suite_name.split('\\') # Windows - else - test_suite_name.split('/') # Unix based - end + test_name = test_suite_name.split(@path_delim) # Remove the extension and extract the base_name base_name = test_name[test_name.size - 1].split('.')[0] @@ -59,7 +56,6 @@ class ParseOutput @test_suite = base_name printf "New Test: %s\n", @test_suite end - end # Test was flagged as having passed so format the output @@ -141,27 +137,24 @@ class ParseOutput @array_list.push ' ' end - # Figure out what OS we are running on. For now we are assuming if it's not Windows it must - # be Unix based. - def detect_os - os = RUBY_PLATFORM.split('-') - @class_name = if os.size == 2 - if os[1] == 'mingw32' - 1 - else - 0 - end - else - 0 - end + # Adjusts the os specific members according to the current path style + # (Windows or Unix based) + def set_os_specifics(line) + if line.include? '\\' + # Windows X:\Y\Z + @class_name = 1 + @path_delim = '\\' + else + # Unix Based /X/Y/Z + @class_name = 0 + @path_delim = '/' + end end # Main function used to parse the file that was captured. def process(name) @array_list = [] - detect_os - puts 'Parsing file: ' + name test_pass = 0 @@ -177,6 +170,7 @@ class ParseOutput # /.c:115:test_tc5100_initCanVoidPtrs:PASS # # where path is different on Unix vs Windows devices (Windows leads with a drive letter) + set_os_specifics(line) line_array = line.split(':') # If we were able to split the line then we can look to see if any of our target words -- GitLab