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_r229731283
##########
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++ {
Review comment:
if I do that I lose my ability to check against the same line in `testLines`
without separate, extra knowledge. However, having now looked up the complete
output of `range`, I can probably just use that (but not with an `_`)
----------------------------------------------------------------
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