dangogh 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_r229712039
##########
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]
+ } else if refLines[i][:13] != "# DO NOT EDIT" {
+ if len(refLines[i]) >= 19 {
Review comment:
wouldn't it be more straightforward to just strip out the comments?
----------------------------------------------------------------
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