You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/11/01 18:00:10 UTC

[GitHub] dangogh commented on a change in pull request #2967: Fixed compare tool generating diffs based on timestamp in configuration file headers

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_r230138596
 
 

 ##########
 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:
   yes -- if you do need the index,  then certainly use `for i, refLine := range refLines`.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services