@@ -34,7 +34,7 @@ func TestErrorTemplate(t *testing.T) {
34
34
35
35
testutils .Equals (t , tmp .Name , "ErrorA" )
36
36
testutils .Equals (t , tmp .Language , lib .TestLanguage )
37
- testutils .Equals (t , tmp .Pattern .String (), `(?m)^This is a sample error(?P<stacktrace>(?:.|\s )*)$` )
37
+ testutils .Equals (t , tmp .Pattern .String (), `(?m)^This is a sample error(?P<stacktrace>(?:\sin \S+ at \S+:\d+ )*)$` )
38
38
testutils .Equals (t , tmp .StackTraceRegex ().String (), `(?m)\sin (?P<symbol>\S+) at (?P<path>\S+):(?P<position>\d+)` )
39
39
testutils .ExpectNil (t , tmp .StackTracePattern )
40
40
})
@@ -54,7 +54,7 @@ func TestErrorTemplate(t *testing.T) {
54
54
55
55
testutils .Equals (t , tmp .Name , "ErrorB" )
56
56
testutils .Equals (t , tmp .Language , lib .TestLanguage )
57
- testutils .Equals (t , tmp .Pattern .String (), `(?m)^This is a sample error with stack trace(?P<stacktrace>(?:.|\s )*)$` )
57
+ testutils .Equals (t , tmp .Pattern .String (), `(?m)^This is a sample error with stack trace(?P<stacktrace>(?:\S+:\S+:\d+ )*)$` )
58
58
testutils .Equals (t , tmp .StackTraceRegex ().String (), `(?P<symbol>\S+):(?P<path>\S+):(?P<position>\d+)` )
59
59
})
60
60
@@ -72,7 +72,7 @@ func TestErrorTemplate(t *testing.T) {
72
72
73
73
testutils .Equals (t , tmp .Name , "ErrorC" )
74
74
testutils .Equals (t , tmp .Language , lib .TestLanguage )
75
- testutils .Equals (t , tmp .Pattern .String (), `(?m)^Stack trace in middle (?P<stacktrace>(?:.|\s )*)test$` )
75
+ testutils .Equals (t , tmp .Pattern .String (), `(?m)^Stack trace in middle (?P<stacktrace>(?:\sin \S+ at \S+:\d+ )*)test$` )
76
76
testutils .ExpectNil (t , tmp .StackTracePattern )
77
77
})
78
78
}
@@ -265,7 +265,7 @@ func TestExtractVariables(t *testing.T) {
265
265
266
266
variables := tmp .ExtractVariables (input )
267
267
exp := map [string ]string {
268
- "stacktrace" : "\n in main at /home/user/main.py:123 \n in main at /home/user/main.py:1 " ,
268
+ "stacktrace" : "" ,
269
269
"input" : "123abc" ,
270
270
}
271
271
@@ -439,6 +439,8 @@ func TestErrorTemplates(t *testing.T) {
439
439
OnGenBugFixFn : emptyBugFixFn ,
440
440
})
441
441
442
+ inputStackTrace := " in Abcd at test.file:10"
443
+
442
444
fmt .Println (tmp .Pattern .String ())
443
445
fmt .Println (tmp2 .Pattern .String ())
444
446
@@ -454,7 +456,10 @@ func TestErrorTemplates(t *testing.T) {
454
456
}
455
457
456
458
for i , input := range inputs {
457
- matched := errorTemplates .Match (input + "\n " + lib .TestLanguage .StackTracePattern )
459
+ matched := errorTemplates .Match (input + "\n " + inputStackTrace )
460
+ if matched == nil {
461
+ t .Fatalf ("expected %s, got nil" , expected [i ].Name )
462
+ }
458
463
459
464
if ! reflect .DeepEqual (matched , expected [i ]) {
460
465
t .Fatalf ("expected %s, got %s" , expected [i ].Name , matched .Name )
@@ -474,7 +479,10 @@ func TestErrorTemplates(t *testing.T) {
474
479
}
475
480
476
481
for i , input := range inputs {
477
- matched := errorTemplates .Match (input + "\n " + lib .TestLanguage .StackTracePattern )
482
+ matched := errorTemplates .Match (input + "\n " + inputStackTrace )
483
+ if matched == nil {
484
+ t .Fatalf ("expected %s, got nil" , expected [i ].Name )
485
+ }
478
486
479
487
if ! reflect .DeepEqual (matched , expected [i ]) {
480
488
t .Fatalf ("expected %s, got %s" , expected [i ].Name , matched .Name )
@@ -486,8 +494,8 @@ func TestErrorTemplates(t *testing.T) {
486
494
inputs := []string {
487
495
"This is a sample errorz\n " ,
488
496
"AAnother exmaple error\n " ,
489
- "Another eaaxmaple error\n " + lib . TestLanguage . StackTracePattern ,
490
- "This is a sample erroar\n " + lib . TestLanguage . StackTracePattern ,
497
+ "Another eaaxmaple error\n " + inputStackTrace ,
498
+ "This is a sample erroar\n " + inputStackTrace ,
491
499
}
492
500
493
501
for _ , input := range inputs {
@@ -505,8 +513,11 @@ func TestErrorTemplates(t *testing.T) {
505
513
"Another exmaple error" ,
506
514
}
507
515
508
- input := strings .Join (inputs , "\n in main at /home/user/main.py:1\n \n " )
516
+ input := strings .Join (inputs , "\n in main at /home/user/main.py:1\n \n " )
509
517
matched := errorTemplates .Match (input )
518
+ if matched == nil {
519
+ t .Fatalf ("expected %s, got nil" , tmp .Name )
520
+ }
510
521
511
522
if ! reflect .DeepEqual (matched , tmp ) {
512
523
t .Fatalf ("expected %s, got %s" , tmp .Name , matched .Name )
@@ -520,8 +531,11 @@ func TestErrorTemplates(t *testing.T) {
520
531
"This is a sample error" ,
521
532
}
522
533
523
- input := strings .Join (inputs , "\n in main at /home/user/main.py:1\n \n " )
534
+ input := strings .Join (inputs , "\n in main at /home/user/main.py:1\n \n " )
524
535
matched := errorTemplates .Match (input )
536
+ if matched == nil {
537
+ t .Fatalf ("expected %s, got nil" , tmp2 .Name )
538
+ }
525
539
526
540
if ! reflect .DeepEqual (matched , tmp2 ) {
527
541
t .Fatalf ("expected %s, got %s" , tmp2 .Name , matched .Name )
0 commit comments