git-codereview: use fromSlash in TestGofmtSubdir* to make them pass on windows

Change-Id: Ic59299a544d2a8887b305b202c0f5da758ff7322
Reviewed-on: https://go-review.googlesource.com/3071
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/git-codereview/gofmt_test.go b/git-codereview/gofmt_test.go
index d720726..de2aae6 100644
--- a/git-codereview/gofmt_test.go
+++ b/git-codereview/gofmt_test.go
@@ -74,20 +74,20 @@
 
 	chdir(t, gt.client)
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "dir1/bad1.go", "longnamedir2/bad2.go")
+	testPrintedStdout(t, fromSlash("dir1/bad1.go"), fromSlash("longnamedir2/bad2.go"))
 
 	chdir(t, gt.client+"/dir1")
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "bad1.go", "!/bad1.go", "longnamedir2/bad2.go")
+	testPrintedStdout(t, "bad1.go", fromSlash("!/bad1.go"), fromSlash("longnamedir2/bad2.go"))
 
 	chdir(t, gt.client+"/longnamedir2")
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "bad2.go", "!/bad2.go", "dir1/bad1.go")
+	testPrintedStdout(t, "bad2.go", fromSlash("!/bad2.go"), fromSlash("dir1/bad1.go"))
 
 	mkdir(t, gt.client+"/z")
 	chdir(t, gt.client+"/z")
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "longnamedir2/bad2.go", "dir1/bad1.go")
+	testPrintedStdout(t, fromSlash("longnamedir2/bad2.go"), fromSlash("dir1/bad1.go"))
 }
 
 func TestGofmtSubdirIndexCheckout(t *testing.T) {
@@ -111,20 +111,20 @@
 
 	chdir(t, gt.client)
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "dir1/bad1.go (staged)", "longnamedir2/bad2.go (staged)")
+	testPrintedStdout(t, fromSlash("dir1/bad1.go (staged)"), fromSlash("longnamedir2/bad2.go (staged)"))
 
 	chdir(t, gt.client+"/dir1")
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "bad1.go (staged)", "!/bad1.go", "longnamedir2/bad2.go (staged)")
+	testPrintedStdout(t, "bad1.go (staged)", fromSlash("!/bad1.go"), fromSlash("longnamedir2/bad2.go (staged)"))
 
 	chdir(t, gt.client+"/longnamedir2")
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "bad2.go (staged)", "!/bad2.go", "dir1/bad1.go (staged)")
+	testPrintedStdout(t, "bad2.go (staged)", fromSlash("!/bad2.go"), fromSlash("dir1/bad1.go (staged)"))
 
 	mkdir(t, gt.client+"/z")
 	chdir(t, gt.client+"/z")
 	testMain(t, "gofmt", "-l")
-	testPrintedStdout(t, "longnamedir2/bad2.go (staged)", "dir1/bad1.go (staged)")
+	testPrintedStdout(t, fromSlash("longnamedir2/bad2.go (staged)"), fromSlash("dir1/bad1.go (staged)"))
 }
 
 func TestGofmtUnstaged(t *testing.T) {
diff --git a/git-codereview/util_test.go b/git-codereview/util_test.go
index 96716b4..8197867 100644
--- a/git-codereview/util_test.go
+++ b/git-codereview/util_test.go
@@ -178,10 +178,14 @@
 	return string(out)
 }
 
-// fromSlash is like filepath.FromSlash, but it ignores ! at the start of the path.
+// fromSlash is like filepath.FromSlash, but it ignores ! at the start of the path
+// and " (staged)" at the end.
 func fromSlash(path string) string {
 	if len(path) > 0 && path[0] == '!' {
-		return "!" + filepath.FromSlash(path[1:])
+		return "!" + fromSlash(path[1:])
+	}
+	if strings.HasSuffix(path, " (staged)") {
+		return fromSlash(path[:len(path)-len(" (staged)")]) + " (staged)"
 	}
 	return filepath.FromSlash(path)
 }