Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail with local ~/.woke.yaml file #163

Closed
cognitivegears opened this issue Nov 17, 2021 · 0 comments · Fixed by #164
Closed

Tests fail with local ~/.woke.yaml file #163

cognitivegears opened this issue Nov 17, 2021 · 0 comments · Fixed by #164
Labels
bug Something isn't working

Comments

@cognitivegears
Copy link
Contributor

Thank you for creating the issue!

  • [ X ] Yes, I've searched similar issues on GitHub and didn't find any.
  • [ X ] Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of woke
$ woke --version
# paste output here

./bin/woke --version
woke version 0.17.0
Config file
$ cat .woke.yml
# paste output here

rules:
  - name: slave
    terms:
      - slave
    alternatives:
      - worker
      - subordinate
      - replica
      - agent
      - secondary
Go environment
$ go version && go env
# paste output here

❯ go version && go env
go version go1.16.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cognitivegears/.cache/go-build"
GOENV="/home/cognitivegears/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/cognitivegears/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/cognitivegears/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.16"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.16/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/cognitivegears/Documents/projects/woke/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1090954941=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running
$ woke --debug
# paste output here

N/A

Issue: Executing the go tests fails if a ~/.woke.yaml file is present. This only happens if the tests for woke/cmd are not cached. In order to duplicate with the test cached, run go test -count=1 ./... with a ~/.woke.yaml file in place.

Below is the results from a sample test run on my machine:

Test run with ~/.woke.yaml present
?   	github.com/get-woke/woke	[no test files]
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"Using config file: /home/cognitivegears/.woke.yaml"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"Using config file: /home/cognitivegears/.woke.yaml"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"Using config file: /home/cognitivegears/.woke.yaml"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"Using config file: /home/cognitivegears/.woke.yaml"}
--- FAIL: TestInitConfig (0.00s)
    --- FAIL: TestInitConfig/no_config (0.00s)
        root_test.go:68:
            	Error Trace:	root_test.go:68
            	Error:      	Not equal:
            	            	expected: ""
            	            	actual  : "/home/cognitivegears/.woke.yaml"
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1 +1 @@
            	            	-
            	            	+/home/cognitivegears/.woke.yaml
            	Test:       	TestInitConfig/no_config
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"woke version main built from 000000 on today"}
{"level":"debug","filename":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"Adding custom ruleset from"}
{"level":"debug","config":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"loaded config file"}
{"level":"debug","error":"open .gitignore: no such file or directory","file":".gitignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .ignore: no such file or directory","file":".ignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .wokeignore: no such file or directory","file":".wokeignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .git/info/exclude: no such file or directory","file":".git/info/exclude","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","durationMS":0.087487,"time":"2021-11-16T21:01:11-06:00","message":"finished compiling ignores"}
{"level":"debug","printer":"text","time":"2021-11-16T21:01:11-06:00","message":"created new printer"}
{"level":"debug","path":"../testdata/good.yml","type":"parallel","time":"2021-11-16T21:01:11-06:00","message":"process files"}
{"level":"debug","durationMS":0.047839,"file":"../testdata/good.yml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.459426,"time":"2021-11-16T21:01:11-06:00","message":"woke completed"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"woke version main built from 000000 on today"}
{"level":"debug","filename":"../testdata/.woke-custom-exit-success.yaml","time":"2021-11-16T21:01:11-06:00","message":"Adding custom ruleset from"}
{"level":"debug","config":"../testdata/.woke-custom-exit-success.yaml","time":"2021-11-16T21:01:11-06:00","message":"loaded config file"}
{"level":"debug","error":"open .gitignore: no such file or directory","file":".gitignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .ignore: no such file or directory","file":".ignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .wokeignore: no such file or directory","file":".wokeignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .git/info/exclude: no such file or directory","file":".git/info/exclude","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","durationMS":0.064392,"time":"2021-11-16T21:01:11-06:00","message":"finished compiling ignores"}
{"level":"debug","printer":"text","time":"2021-11-16T21:01:11-06:00","message":"created new printer"}
{"level":"debug","path":"../testdata/good.yml","type":"parallel","time":"2021-11-16T21:01:11-06:00","message":"process files"}
{"level":"debug","durationMS":0.063209,"file":"../testdata/good.yml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.230766,"time":"2021-11-16T21:01:11-06:00","message":"woke completed"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"woke version main built from 000000 on today"}
{"level":"debug","filename":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"Adding custom ruleset from"}
{"level":"debug","config":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"loaded config file"}
{"level":"debug","error":"open .gitignore: no such file or directory","file":".gitignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .ignore: no such file or directory","file":".ignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .wokeignore: no such file or directory","file":".wokeignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .git/info/exclude: no such file or directory","file":".git/info/exclude","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","durationMS":0.057834,"time":"2021-11-16T21:01:11-06:00","message":"finished compiling ignores"}
{"level":"debug","printer":"text","time":"2021-11-16T21:01:11-06:00","message":"created new printer"}
{"level":"debug","path":"../testdata","type":"parallel","time":"2021-11-16T21:01:11-06:00","message":"process files"}
{"level":"debug","durationMS":0.122945,"file":"../testdata/invalid.yaml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","file":"../testdata","reason":"file is a directory","time":"2021-11-16T21:01:11-06:00","message":"skipping content"}
{"level":"debug","durationMS":0.019636,"file":"../testdata","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.041956,"file":"../testdata/good.yml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.052006,"file":"../testdata/whitelist.yml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.052756,"file":"../testdata/.woke-custom-exit-success.yaml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.758427,"time":"2021-11-16T21:01:11-06:00","message":"woke completed"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"woke version main built from 000000 on today"}
{"level":"debug","filename":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"Adding custom ruleset from"}
{"level":"debug","config":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"loaded config file"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"disabling default rules"}
{"level":"debug","error":"open .gitignore: no such file or directory","file":".gitignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .ignore: no such file or directory","file":".ignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .wokeignore: no such file or directory","file":".wokeignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .git/info/exclude: no such file or directory","file":".git/info/exclude","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","durationMS":0.053914,"time":"2021-11-16T21:01:11-06:00","message":"finished compiling ignores"}
{"level":"debug","printer":"text","time":"2021-11-16T21:01:11-06:00","message":"created new printer"}
{"level":"debug","path":"../testdata","type":"parallel","time":"2021-11-16T21:01:11-06:00","message":"process files"}
{"level":"debug","durationMS":0.121333,"file":"../testdata/invalid.yaml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","file":"../testdata","reason":"file is a directory","time":"2021-11-16T21:01:11-06:00","message":"skipping content"}
{"level":"debug","durationMS":0.020675,"file":"../testdata","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.038437,"file":"../testdata/good.yml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.04781,"file":"../testdata/whitelist.yml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.052806,"file":"../testdata/.woke-custom-exit-success.yaml","time":"2021-11-16T21:01:11-06:00","message":"finished processing findings"}
{"level":"debug","durationMS":0.722755,"time":"2021-11-16T21:01:11-06:00","message":"woke completed"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"woke version main built from 000000 on today"}
{"level":"debug","filename":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"Adding custom ruleset from"}
{"level":"debug","config":"/home/cognitivegears/.woke.yaml","time":"2021-11-16T21:01:11-06:00","message":"loaded config file"}
{"level":"debug","error":"open .gitignore: no such file or directory","file":".gitignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .ignore: no such file or directory","file":".ignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .wokeignore: no such file or directory","file":".wokeignore","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","error":"open .git/info/exclude: no such file or directory","file":".git/info/exclude","time":"2021-11-16T21:01:11-06:00","message":"skipping ignorefile"}
{"level":"debug","durationMS":0.066092,"time":"2021-11-16T21:01:11-06:00","message":"finished compiling ignores"}
{"level":"debug","durationMS":0.321887,"time":"2021-11-16T21:01:11-06:00","message":"woke completed"}
{"level":"debug","time":"2021-11-16T21:01:11-06:00","message":"woke version main built from 000000 on today"}
{"level":"debug","filename":"../testdata/invalid.yaml","time":"2021-11-16T21:01:11-06:00","message":"Adding custom ruleset from"}
{"level":"debug","durationMS":0.072278,"time":"2021-11-16T21:01:11-06:00","message":"woke completed"}
--- FAIL: TestRunE (0.00s)
    --- FAIL: TestRunE/no_rules_enabled (0.00s)
        root_test.go:133:
            	Error Trace:	root_test.go:133
            	Error:      	An error is expected but got nil.
            	Test:       	TestRunE/no_rules_enabled
        root_test.go:134:
            	Error Trace:	root_test.go:134
            	Error:      	Target error should be in err chain:
            	            	expected: "no rules enabled: either configure rules in your config file or remove the `--disable-default-rules` flag"
            	            	in chain:
            	Test:       	TestRunE/no_rules_enabled
FAIL
FAIL	github.com/get-woke/woke/cmd	0.008s
?   	github.com/get-woke/woke/cmd/docs	[no test files]
ok  	github.com/get-woke/woke/pkg/config	0.620s
ok  	github.com/get-woke/woke/pkg/ignore	0.019s
?   	github.com/get-woke/woke/pkg/output	[no test files]
ok  	github.com/get-woke/woke/pkg/parser	0.012s
ok  	github.com/get-woke/woke/pkg/printer	0.010s
ok  	github.com/get-woke/woke/pkg/result	0.006s
ok  	github.com/get-woke/woke/pkg/rule	0.010s
ok  	github.com/get-woke/woke/pkg/util	0.002s
ok  	github.com/get-woke/woke/pkg/walker	0.002s
FAIL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant