xk6
xk6 copied to clipboard
Using 'xk6 run --with' should be possible
Currently 'xk6 run --with' will correctly build the binary(including the correct extensions), but then will also send the --with
to the k6 which will at that point exit with an error as it doesn't know of such a flag.
Hey, I think this is a docs issue, as it's working as designed. See the plugin development section.
If you run xk6
without build
it will build a k6
binary with the extension in the CWD and passthrough any arguments to the parent command (k6
in this case). It's meant to be used as a quick way to test extensions while developing, so I think it's a useful feature. So the run
in your example is interpreted by k6
, not xk6
. :)
One thing to keep in mind is that it will run k6
and not ./k6
(i.e. the executable just built), so if k6
is already in your PATH
, it will seem like nothing happened and k6 will complain about a missing module. I think it would be safe to invoke ./k6
and .\k6.exe
here instead to avoid the PATH
issue: https://github.com/k6io/xk6/blob/master/cmd/xk6/main.go#L140-L145
I'll propose that change in an upcoming PR.
One thing to keep in mind is that it will run k6 and not ./k6 (i.e. the executable just built), so if k6 is already in your PATH, it will seem like nothing happened and k6 will complain about a missing module. I think it would be safe to invoke ./k6 and .\k6.exe here instead to avoid the PATH issue: https://github.com/k6io/xk6/blob/master/cmd/xk6/main.go#L140-L145
Hm I think this is why I decided that I actually need to use the --with
... I guess it will be more correct to build it in a temp dir and use it directly from there ?