Mage check doesn't work

Hello,

I am venturing into creating a PR to fix the missing height arg in figure shortcode issue. So I read the CONTRIBUTING.md, and before creating my fork, I installed mage and mage hugo generated the hugo binary fine in the github.com/gohugoio/hugo directory.

Now, here’s where I stumble… mage check in the freshly cloned hugo repo fails without any useful debug info (see below):

I am not a Go developer, so I’ll need guidance to help provide more debug info.

Copying @natefinch .

Run mage -v check

Here’s what I got on mage -v check > mage_check_log.txt:

Looking at the errors, I don’t understand what this has to do with the asciidoc binary in my $PATH, but if it helps, my asciidoc version is 8.6.9.


Unrelated… but I also see:

Skip Pygments test case as no pygments present.

The Pygments binary is pygmentize, not pygments. pygmentize -V returns this on my system:

Pygments version 2.2.0, © 2006-2017 by Georg Brandl.

So, the asciidoc tests fail, for some reason on your machine. Impossible for me to debug, but those same test should pass fine if you create a PR and run the same tests on Travis and friend.

Is this related? https://github.com/gohugoio/hugo/issues/1437

Can I run at least the tests I add to the PR, just those? And know if they passed?

For example, if I add a new test called TestFigureImgHeight, can I run just that using mage? That will give me a better confidence when pushing the PR.

As I said, hard for me to say. Maybe. We could consider just running those tests when on CI (they currently checks for an asciidoc or asciidoctor installation), but I really like having those tests there as a failsafe. I don’t sue Asciidoc nor RST in my daily Hugo life, so it is easy for me to make some change that mucks everything.

You can run

go test -run="SomeRegexp"

To match only the tests you want.

Sorry I am still missing something:

I did

km²~/go.apps/:../github.com/kaushalmodi/hugo> go test -v -run=".*TestFigureImgWidth.*"
?       github.com/kaushalmodi/hugo     [no test files]

I intentionally messed up the TestFigureImgWidth test so that I can see it fail… but go test gives just that… no PASS or FAIL. Can you tell me what exact command you would run to test just that specific test (that I just linked)?


I get the same when trying it in $GOPATH/src/github.com/gohugoio/hugo instead of in my workarea (after intentionally messing up that test):

km²~/go.apps/:../github.com/gohugoio/hugo> go test -v -run=".*TestFigureImgWidth.*"
?       github.com/gohugoio/hugo        [no test files]

go test -run=“SomeRegexp” ./…

This happens when I type from memory.

Thanks! Now I can make some progress.

Though looks like I cannot run tests from my workarea… need to work in the original hugo repo only, else I get:

tpl/cast/docshelper.go:19:2: use of internal package not allowed
tpl/collections/init.go:18:2: use of internal package not allowed
tpl/compare/init.go:18:2: use of internal package not allowed
tpl/crypto/init.go:18:2: use of internal package not allowed
tpl/data/init.go:18:2: use of internal package not allowed
tpl/encoding/init.go:18:2: use of internal package not allowed
tpl/fmt/init.go:18:2: use of internal package not allowed
tpl/images/init.go:18:2: use of internal package not allowed
tpl/inflect/init.go:18:2: use of internal package not allowed
tpl/lang/init.go:18:2: use of internal package not allowed
tpl/math/init.go:18:2: use of internal package not allowed
tpl/os/init.go:18:2: use of internal package not allowed
tpl/partials/init.go:18:2: use of internal package not allowed
tpl/safe/init.go:18:2: use of internal package not allowed
tpl/strings/init.go:18:2: use of internal package not allowed
tpl/time/init.go:18:2: use of internal package not allowed
tpl/tplimpl/template_funcs.go:21:2: use of internal package not allowed
tpl/transform/init.go:18:2: use of internal package not allowed
tpl/urls/init.go:18:2: use of internal package not allowed

But at least I can make the test fail from the hugo repo… so will continue from there.

I suspect that issue goes away with >= Go 1.9.

I am on go1.9.2. Do I need some env var setting to prevent that issue?

Hello,

I am stuck at running tests once again. This time I am using Go 1.9.3.

I added a new test in hugo workarea in hugolib/shortcode_test.go:

func TestFigureLinkNoTarget(t *testing.T) {
	t.Parallel()
	CheckShortCodeMatch(t, `{{% figure src="/found/here" link="/jump/here/on/clicking" %}}`, "\n<figure >\n    <a href="/jump/here/on/clicking">\n        <img src="/found/here" />\n        </a>\n\n</figure>\n", nil)
}

… and like before, I’d like to run only that 1 test. So I did:

go test -run="TestFigureLinkNoTarget" ./...

This (that command syntax) used to work when I last posted this, but today, I am getting this error.

FYI, the usual hugo building from source works fine.


I’ve tried the CONTRIBUTING instructions too:

mage hugoRace
mage -v check

But they fail as well (fail log).

I would guess an issue with GOPATH (missing, wrong). But this is hard to debug by forum…

Try mage vendor.

Actually, I just got it working and I saw your reply.

I had to \rm -rf vendor.orig from within the hugo repo dir. Would mage vendor also have included that step? After deleting that dir, the go test .. command works fine.

No, mage vendor only syncs the vendor/ directory.

@kaushalmodi can you please tell me how you were able to solve these errors when you were trying to test locally?

I also get the use of internal package not allowed error when I try for example:

go test -run="TestShortcodeVimeo" ./...

OR

mage vendor hugoRace
mage -v check

Also I don’t see a vendor.orig in the hugo repo dir of my fork. I only see a vendor directory and removing it doesn’t seem to make a difference in the errors I get when trying to run the test.

P.S. I know what the rm -rf command is about but I just don’t feel comfortable to play with it, even in the form of \rm -rf vendor.orig

Not a Go expert, but I’ve learned that such strange errors cropped up if I ran those commands in my cloned fork of Hugo.

I’m assuming you are already doing this, but you need to be in the original Hugo cloned go apps work area, and run the build and test commands from there.

1 Like

Ok. Thanks.