Comments (4)
Does ${ROOTDIR}
help?
https://github.com/google/go-cmdtest#variable-substitution
from go-cmdtest.
No,
i try this:
- [Archfile] path '$.components.not_exist.in': not found directories for 'not_exist' in '/home/neo/go/src/github.com/fe3dback/go-arch-lint/test/check/project/not_exist':
+ [Archfile] path '$.components.not_exist.in': not found directories for 'not_exist' in '${ROOTDIR}/test/check/project/not_exist':
After fix, test failed with error:
cmdtest.go:294: test/check/invalid_spec.ct:1: got=-, want=+
$ go-arch-lint check --project-path ${PWD}/test/check/project --arch-file invalid_spec.yml --output-color=false --> FAIL
[]string{
... // 7 identical elements
" 25 | deps:",
" 26 | main:",
strings.Join({
"[Archfile] path '$.components.not_exist.in': not found directori",
"es for 'not_exist' in '",
- "/home/neo/go/src/github.com/fe3dback/go-arch-lint",
+ "${ROOTDIR}",
"/test/check/project/not_exist':",
}, ""),
" 14 | main:",
" 15 | in: .",
... // 36 identical elements
}
from go-cmdtest.
It looks like we do try to scrub the ${ROOTDIR}
, here:
https://github.com/google/go-cmdtest/blob/master/cmdtest.go#L598
Is that path somewhere else? You might have to update the path to be relative to the test directory, or otherwise scrub it.
from go-cmdtest.
This ROOTDIR
point to temporary dir like /tmp/cmdtest083165588
, but i find solution for this:
Overriding ROOTDIR
in testcase setup:
func TestCLI(t *testing.T) {
ts, err := cmdtest.Read("test/**")
if err != nil {
t.Fatal(err)
}
+ ts.Setup = func(_ string) error {
+ _, testFileName, _, ok := runtime.Caller(0)
+ if !ok {
+ return fmt.Errorf("failed get real working directory from caller")
+ }
+
+ projectRootDir := filepath.Dir(testFileName)
+ if err := os.Setenv("ROOTDIR", projectRootDir); err != nil {
+ return fmt.Errorf("failed change 'ROOTDIR' to caller working directory: %v", err)
+ }
+
+ return nil
+ }
ts.Commands[binaryName] = cmdtest.InProcessProgram(binaryName, run)
ts.Run(t, *update)
}
}
And now ${ROOTDIR}
is working fine.
from go-cmdtest.
Related Issues (8)
- go-cmdtest does not work on Windows anymore HOT 6
- Previous commands preventing new commands from running correctly. HOT 2
- check exit codes
- Filtering output support HOT 9
- build error on Plan 9: undefined: syscall.Errno
- Handle different mount points when generating output via update feature
- Release a new version HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-cmdtest.