On Thu, Aug 20, 2020 at 07:04:40PM +0800, Lu Kaiyi wrote:
fix syntax problem in line with crystal
- single-quotes to double-quotes
- $PROGRAM_NAME to PROGRAM_NAME
- stats = [] to stats = [] of String
- add type = "" before using
Signed-off-by: Lu Kaiyi lukaiyi@huawei.com
stats/crystal/test-bpf.cr | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/stats/crystal/test-bpf.cr b/stats/crystal/test-bpf.cr index f5b13a09..3941a110 100644 --- a/stats/crystal/test-bpf.cr +++ b/stats/crystal/test-bpf.cr @@ -1,46 +1,45 @@ -#!/usr/bin/env ruby +#!/usr/bin/env crystal
-LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.reapath($PROGRAM_NAME))) +LKP_SRC = ENV["LKP_SRC"] || File.dirname(File.dirname(File.real_path(PROGRAM_NAME)))
-require "#{LKP_SRC}/lib/string_ext" +require "../../lib/string_ext"
-stats = [] +stats = [] of String success_test = 0 fail_test = 0 is_divided = false
while (line = STDIN.gets)
- line = line.remediate_invalid_byte_sequence(replace: '_') unless line.valid_encoding?
- case line when /test_bpf: #[0-9]+ (.+) jited:.+ PASS$/
- type = $1.tr(' ', '_')
- stats << type + '.pass: 1'
- type = $1.tr(" ", "_")
- stats << type + ".pass: 1" when /test_bpf: #[0-9]+ (.+) jited:.+ FAIL/
- type = $1.tr(' ', '_')
- stats << type + '.fail: 1'
- type = $1.tr(" ", "_")
- stats << type + ".fail: 1" when /test_bpf: #[0-9]+ check: (.+) PASS$/
- type = $1.tr(' ', '_')
- stats << 'check:_' + type + '.pass: 1'
- type = $1.tr(" ", "_")
- stats << "check:_" + type + ".pass: 1" when /test_bpf: #[0-9]+ check: (.+) FAIL/
- type = $1.tr(' ', '_')
- stats << 'check:_' + type + '.fail: 1'
- type = $1.tr(" ", "_")
- stats << "check:_" + type + ".fail: 1" when /test_bpf: #[0-9]+ (.+) PASS$/
- type = $1.tr(' ', '_')
- stats << type + '.pass: 1'
- type = $1.tr(" ", "_")
- stats << type + ".pass: 1" when /test_bpf: #[0-9]+ (.+) FAIL/
- type = $1.tr(' ', '_')
- stats << type + '.fail: 1'
- type = $1.tr(" ", "_")
- stats << type + ".fail: 1" when /test_bpf: #[0-9]+ check: (.+)/
- type = 'check:_' + $1.strip.tr(' ', '_')
- type = "check:_" + $1.strip.tr(" ", "_") is_divided = true when /test_bpf: #[0-9]+ (.+)/
- type = $1.strip.tr(' ', '_')
- type = $1.strip.tr(" ", "_") is_divided = true when /test_bpf: Summary: ([0-9]+) PASSED, ([0-9]+) FAILED, [.+ JIT'ed]$/ success_test = $1 fail_test = $2 when /(PASS|FAIL)/
- type = ""
"type" should not be null here,the content of "type" will be lost. I think you can put it at the beginning of the program.
Thanks Shengrui
if is_divided stats << type + ".#{$1.downcase}: 1" is_divided = false
-- 2.23.0