This is an automated email from the ASF dual-hosted git repository.

dgrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new a2fde75  Fix regex for log stripping. (#462)
a2fde75 is described below

commit a2fde75ab5a8309eedb9c7649bcfe232c91b07eb
Author: rodric rabbah <[email protected]>
AuthorDate: Fri Nov 1 09:07:07 2019 -0400

    Fix regex for log stripping. (#462)
---
 commands/util.go      |  2 +-
 commands/util_test.go | 28 +++++++++++++++-------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/commands/util.go b/commands/util.go
index c3fd752..0a4e873 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -277,7 +277,7 @@ func stripTimestamp(log string) (strippedLog string) {
        // the timestamp expected format is YYYY-MM-DDTHH:MM:SS.[0-9]+Z
        // an optional " stdout" or " stderr" stream identifier
        // and the rest as the log line
-       regex := 
regexp.MustCompile("\\d{4}-[01]{1}\\d{1}-[0-3]{1}\\d{1}T[0-2]{1}\\d{1}:[0-6]{1}\\d{1}:[0-6]{1}\\d{1}.\\d+Z(
 (stdout|stderr):)?\\s(.*)")
+       regex := 
regexp.MustCompile("\\d{4}-[01]{1}\\d{1}-[0-3]{1}\\d{1}T[0-2]{1}\\d{1}:[0-6]{1}\\d{1}:[0-6]{1}\\d{1}.\\d+Z(
 *(stdout|stderr):)?\\s(.*)")
        match := regex.FindStringSubmatch(log)
 
        if len(match) > 3 && len(match[3]) > 0 {
diff --git a/commands/util_test.go b/commands/util_test.go
index 1350d8a..67e26b0 100644
--- a/commands/util_test.go
+++ b/commands/util_test.go
@@ -26,19 +26,21 @@ import (
 
 func TestStripTimestamp(t *testing.T) {
        logs := map[string]string{
-               "2018-05-02T19:33:32.829992819Z stdout: this is stdout stderr: 
this is still stdout": "this is stdout stderr: this is still stdout",
-               "2018-05-02T19:33:32.829992819Z stderr: this is stderr stdout: 
this is still stderr": "this is stderr stdout: this is still stderr",
-               "2018-05-02T19:33:32.89Z stdout: this is stdout":               
                      "this is stdout",
-               "2018-05-02T19:33:32.89Z this is a msg":                        
                      "this is a msg",
-               "2018-05-02T19:33:32.89Z  this is a msg":                       
                      " this is a msg",
-               "anything stdout: this is stdout":                              
                      "anything stdout: this is stdout",
-               "anything stderr: this is stderr":                              
                      "anything stderr: this is stderr",
-               "stdout: this is stdout":                                       
                      "stdout: this is stdout",
-               "stderr: this is stderr":                                       
                      "stderr: this is stderr",
-               "this is stdout":                                               
                      "this is stdout",
-               "this is stderr":                                               
                      "this is stderr",
-               "something":                                                    
                      "something",
-               "":                                                             
                      ""}
+               "2018-05-02T19:33:32.829992819Z stdout: this is stdout stderr: 
this is still stdout":  "this is stdout stderr: this is still stdout",
+               "2018-05-02T19:33:32.829992819Z stderr: this is stderr stdout: 
this is still stderr":  "this is stderr stdout: this is still stderr",
+               "2018-05-02T19:33:32.829992819Z  stdout: this is stdout stderr: 
this is still stdout": "this is stdout stderr: this is still stdout",
+               "2018-05-02T19:33:32.829992819Z  stderr: this is stderr stdout: 
this is still stderr": "this is stderr stdout: this is still stderr",
+               "2018-05-02T19:33:32.89Z stdout: this is stdout":               
                       "this is stdout",
+               "2018-05-02T19:33:32.89Z this is a msg":                        
                       "this is a msg",
+               "2018-05-02T19:33:32.89Z  this is a msg":                       
                       " this is a msg",
+               "anything stdout: this is stdout":                              
                       "anything stdout: this is stdout",
+               "anything stderr: this is stderr":                              
                       "anything stderr: this is stderr",
+               "stdout: this is stdout":                                       
                       "stdout: this is stdout",
+               "stderr: this is stderr":                                       
                       "stderr: this is stderr",
+               "this is stdout":                                               
                       "this is stdout",
+               "this is stderr":                                               
                       "this is stderr",
+               "something":                                                    
                       "something",
+               "":                                                             
                       ""}
        assert := assert.New(t)
 
        for log, expected := range logs {

Reply via email to