cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

Tests Panic on Windows #68

Open cambefus opened 4 years ago

cambefus commented 4 years ago

This is likely a Newbie issue (aka Id10t). I have just brought down the library (go get) to my windows 10 computer. Attempting to run tests on the code results in the following...

MINGW64 ~/go/src/github.com/cavaliercoder/grab (master)
$ go test .
--- FAIL: TestFilenameResolution (0.25s)
    --- FAIL: TestFilenameResolution/Using_Content-Disposition_Header_with_target_directory (0.05s)
        client_test.go:70: Filename mismatch. Expected '.test/header-filename', got '.test\header-filename'.
    --- FAIL: TestFilenameResolution/Using_URL_Path_with_target_directory (0.05s)
        client_test.go:70: Filename mismatch. Expected '.test/url-filename', got '.test\url-filename'.
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x6bff14]

goroutine 1592 [running]:
testing.tRunner.func1(0xc00037a900)
        C:/Go/src/testing/testing.go:874 +0x3aa
panic(0x71f480, 0xa05920)
        C:/Go/src/runtime/panic.go:679 +0x1c0
github.com/cavaliercoder/grab.guessFilename(0xc000471ed0, 0xc00000a0f8, 0x787a34, 0x3, 0x78fc61)
        C:/Users/camer/go/src/github.com/cavaliercoder/grab/util.go:51 +0x34
github.com/cavaliercoder/grab.TestURLFilenames.func2(0xc00037a900)
        C:/Users/camer/go/src/github.com/cavaliercoder/grab/util_test.go:54 +0x12a
testing.tRunner(0xc00037a900, 0x7a3bb8)
        C:/Go/src/testing/testing.go:909 +0xd0
created by testing.(*T).Run
        C:/Go/src/testing/testing.go:960 +0x357
FAIL    github.com/cavaliercoder/grab   3.666s
FAIL
 ---

I am not fussed about the filename fails, but the panic has me blocked. I get the same error when attempting to use the library in my own code. Any suggestions are appreciated.

cavaliercoder commented 4 years ago

Not a noob question at all. Looks like a legit bug. Firstly I can see that director separators are a problem on windows so we’ll need to fix that. The nil deref panic is not obvious to me right now, so I’ll take a look when I get home and try get you unblocked. Thanks for reporting!

oliverpool commented 4 years ago

@cavaliercoder I think the panic is not related to windows, but to a "recent" version of go (#72 probably fixes the panic).