ocket8888 commented on a change in pull request #2967: Fixed compare tool 
generating diffs based on timestamp in configuration file headers
URL: https://github.com/apache/trafficcontrol/pull/2967#discussion_r229729893
 
 

 ##########
 File path: traffic_ops/testing/compare/compare.go
 ##########
 @@ -138,7 +138,59 @@ func testRoute(tos []*Connect, route string) {
        wg.Wait()
        close(ch)
 
-       if res[0].Res == res[1].Res {
+       // Check for Traffic Ops headers and remove them before comparison
+       refResult := res[0].Res
+       testResult := res[1].Res
+       if strings.Contains(route, "configfiles") {
+               refLines := strings.Split(refResult, "\n")
+               testLines := strings.Split(testResult, "\n")
+
+               // If the two files have different numbers of lines, they 
definitely differ
+               if len(refLines) != len(testLines) {
+                       log.Print("Diffs from ", route, " written to")
+                       p, err := res[0].TO.writeResults(route, refResult)
+                       if err != nil {
+                               log.Fatal("Error writing results for ", route)
+                       }
+                       log.Print(" ", p)
+                       p, err = res[1].TO.writeResults(route, testResult)
+                       if err != nil {
+                               log.Fatal("Error writing results for ", route)
+                       }
+                       log.Print(" and ", p)
+               }
+
+               refResult = ""
+               testResult = ""
+
+               for i := 0; i < len(refLines); i++ {
+                       if len(refLines[i]) < 13 {
+                               refResult += refLines[i]
 
 Review comment:
   It specifically checks for the length of the string it will check for 
equality, to avoid slicing a line longer than it actually is. If you'd prefer, 
I can make the strings global and check against their length instead, but doing 
it in a truly modular way would require iterating over/sorting some list of 
strings to strip out, which to me seemed needlessly expensive for such a 
specific, simple task.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to