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

Set working dir to the current one if test is read from stdin #3676

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

mstoykov
Copy link
Collaborator

@mstoykov mstoykov commented Apr 5, 2024

What?

Usually the working dir for a given script is set based on it's path.

For test from stdin that path is file:///- so it is basically the root folder. With this change this changes to the directory k6 was ran from.

This means when you do cat script.js | k6 run - the working dir will be the same as if you did k6 run script.js.

But there is still no way to fix cat path/to/somewhere/script.js | k6 run - as k6 can't know where it got it's stdin from.

fixes #1462

Why?

Fixing the issue and potentially having less people report it

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

This is marked as breaking change as it changes the behaviour - arguably most people expect the new behaviour, so I expect no users actually depend on the current one.

Usually the working dir for a given script is set based on it's path.

For test from stdin that path is file:///- so it is basically the root
folder. With this change this changes to the directory k6 was ran from.

This means when you do `cat script.js | k6 run -` the working dir will
be the same as if you did `k6 run script.js`.

But there is still no way to fix `cat path/to/somewhere/script.js | k6
run -` as k6 can't know where it got it's stdin from.

fixes #1462
@mstoykov mstoykov added the breaking change for PRs that need to be mentioned in the breaking changes section of the release notes label Apr 5, 2024
@mstoykov mstoykov added this to the v0.51.0 milestone Apr 5, 2024
@mstoykov mstoykov requested a review from a team as a code owner April 5, 2024 13:09
@mstoykov mstoykov requested review from codebien and joanlopez and removed request for a team April 5, 2024 13:09
@codebien
Copy link
Collaborator

codebien commented Apr 5, 2024

But there is still no way to fix cat path/to/somewhere/script.js | k6 run -

It sounds like a nice to have from your point of view. Why? The new behavior sounds like the final solution to me.

@mstoykov
Copy link
Collaborator Author

mstoykov commented Apr 5, 2024

@codebien this was mostly just pointing out that this will still not work.

Not that I do think that there is a way to do it or that we should do something more. As you see I am closing the issue with the commit and the PR.

@mstoykov mstoykov merged commit dc37629 into master Apr 8, 2024
23 of 25 checks passed
@mstoykov mstoykov deleted the fix1462 branch April 8, 2024 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change for PRs that need to be mentioned in the breaking changes section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

k6 path resolution doesn't work from CWD when running from stdin
3 participants