Merge lp:~jameinel/gocheck/win32-tests into lp:gocheck

Proposed by John A Meinel
Status: Merged
Approved by: Gustavo Niemeyer
Approved revision: 61
Merged at revision: 81
Proposed branch: lp:~jameinel/gocheck/win32-tests
Merge into: lp:gocheck
Diff against target: 35 lines (+10/-2)
2 files modified
.bzrignore (+1/-0)
gocheck.go (+9/-2)
To merge this branch: bzr merge lp:~jameinel/gocheck/win32-tests
Reviewer Review Type Date Requested Status
Gustavo Niemeyer Pending
Review via email: mp+66793@code.launchpad.net

Commit message

Transform '\' separated paths to '/' so that the tests pass on Windows.

Description of the change

This fixes a bunch of failing tests on Windows.

Specifically, a lot of tests were asserting something like:

FAIL: filename.go ...

While on Windows, the full paths are given:

FAIL: C:/dev/go/gocheck/filename.go

I dug into it, and it turns out that nicePath was comparing
function.FileLine() to os.Getwd(). However, function.FileLine() returns
'C:/path/to/foo' while 'os.Getwd()' returns 'C:\path\to\foo'.

I also did one more quick change, which was to always append the trailing '/'.
That way we don't have to do that on every call to nicePath() (and I checked
that only nicePath uses initWD).

At the moment, there are only 2 remaining tests failing. Both because the
failure messages don't include the module name. This is with golang r58. So it
is possible that golang changed something (so it needs to be fixed anyway), or
it is possible it just works differently on Windows :(.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

The regexp thing seems to have been triggered by this commit:
http://code.google.com/p/go/source/detail?spec=svn67b160cd5fa47f3703c503e7fd65c23e9213d2a9&r=fc5e8036769a1fec534911f3720de426755670ef

I'm not sure why a commit from June 16th isn't in r58, but whatever, I'll survive. Annoying to have the tests that tightly tied to the exact version of go you are running with.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Hey John,

I apologize it took me a while to get to this, but I'd like to get it merged.

Do you have any other recent changes, or have you been using this as-is?

Revision history for this message
John A Meinel (jameinel) wrote :

That was all I needed to change at the time, I haven't been playing with go much for the last month or so.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Alright.. I'll hope for the best and submit this.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

*** Submitted:

This fixes a bunch of failing tests on Windows.

Specifically, a lot of tests were asserting something like:

FAIL: filename.go ...

While on Windows, the full paths are given:

FAIL: C:/dev/go/gocheck/filename.go

I dug into it, and it turns out that nicePath was comparing
function.FileLine() to os.Getwd(). However, function.FileLine() returns
'C:/path/to/foo' while 'os.Getwd()' returns 'C:\path\to\foo'.

I also did one more quick change, which was to always append the trailing '/'.
That way we don't have to do that on every call to nicePath() (and I checked
that only nicePath uses initWD).

At the moment, there are only 2 remaining tests failing. Both because the
failure messages don't include the module name. This is with golang r58. So it
is possible that golang changed something (so it needs to be fixed anyway), or
it is possible it just works differently on Windows :(.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-11-06 17:09:32 +0000
3+++ .bzrignore 2011-07-04 13:48:36 +0000
4@@ -1,2 +1,3 @@
5 _*
6 [856].out
7+[856].out.exe
8
9=== modified file 'gocheck.go'
10--- gocheck.go 2011-04-28 11:02:15 +0000
11+++ gocheck.go 2011-07-04 13:48:36 +0000
12@@ -260,10 +260,16 @@
13
14 var initWD, initWDErr = os.Getwd()
15
16+func init() {
17+ if initWDErr == nil {
18+ initWD = strings.Replace(initWD, "\\", "/", -1) + "/"
19+ }
20+}
21+
22 func nicePath(path string) string {
23 if initWDErr == nil {
24- if strings.HasPrefix(path, initWD+"/") {
25- return path[len(initWD)+1:]
26+ if strings.HasPrefix(path, initWD) {
27+ return path[len(initWD):]
28 }
29 }
30 return path
31@@ -796,3 +802,4 @@
32 return fmt.Sprintf("%s%s: %s: %s%s", prefix, label, niceFuncPath(pc),
33 niceFuncName(pc), suffix)
34 }
35+

Subscribers

People subscribed via source and target branches