-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Remove WriteFile and move it into CopyFile #204
Conversation
- I've removed the WriteFile and put it into CopyFile. - It still uses filesytem.Split but just to get the directory name to create it if it doesn't exist. - It opens the file with os.OpenFile and set the file permissions there instead of after copying. - It removes the file if io.Copy returns an error. - It doesn't need error handling on toFile.Close as it only returns an error if it's called multiple times.
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/vercel/turbo-site/3R4mnhZPU4TScGGwjYhfqinmMHbb |
This is roughly 2-3x slower on my benchmarks |
I'm not sure how it could be that much slower, it's practically the same apart from:
It could be that this one removes the file if there's an error copying, wheras the old implementation didn't bother. If you're on windows the old one could be running quicker due to the bug this is meant to fix. This one also avoids the need for creating a temporary file and renaming it. |
Run I will formally benchmark again tomorrow |
If I don't figure out what caused it it would probably be best to revert the commit and just replace |
The only change is changing path.Split -> filepath.Split
I’ve reverted merging |
This is a very early version of the next-dev test runner. I'm opening this early to get thoughts from folks re: the direction of the design and implementation. Fixes #204 Currently it: * Discovers integration test fixtures from the filesystem. Right now these are expected to be single files that get bundled and will eventually include assertions. This is powered by the test-generator crate, which allows us not to have to manually enumerate each case. We could consider using this for the node-file-trace tests as well. * Starts the dev server on a free port and opens a headless browser to its root. The browser control is implemented with the https://crates.io/crates/chromiumoxide crate, which expects Chrome or Chromium to already be available. Eventually it will: * [x] Implement a minimal test environment loaded in the browser so that assertions can be run there from bundled code. * [x] Report back the results of these assertions to rust, where we can pass/fail cargo tests with those results. In the future it could: * Possibly include snapshot-style tests to assert on transformed results. This could be in the form of fixture directories instead of files cc @jridgewell * Support expressing special configuration of turbopack in a fixture, possibly as another file in the fixture directory. * [x] ~Possibly support distributing tests to a pool of open browsers instead of opening and closing for each test.~ Test Plan: See next PRs
Co-authored-by: Henry Heffernan <henryheffernan@gmail.com>
This is a very early version of the next-dev test runner. I'm opening this early to get thoughts from folks re: the direction of the design and implementation. Fixes vercel/turborepo#204 Currently it: * Discovers integration test fixtures from the filesystem. Right now these are expected to be single files that get bundled and will eventually include assertions. This is powered by the test-generator crate, which allows us not to have to manually enumerate each case. We could consider using this for the node-file-trace tests as well. * Starts the dev server on a free port and opens a headless browser to its root. The browser control is implemented with the https://crates.io/crates/chromiumoxide crate, which expects Chrome or Chromium to already be available. Eventually it will: * [x] Implement a minimal test environment loaded in the browser so that assertions can be run there from bundled code. * [x] Report back the results of these assertions to rust, where we can pass/fail cargo tests with those results. In the future it could: * Possibly include snapshot-style tests to assert on transformed results. This could be in the form of fixture directories instead of files cc @jridgewell * Support expressing special configuration of turbopack in a fixture, possibly as another file in the fixture directory. * [x] ~Possibly support distributing tests to a pool of open browsers instead of opening and closing for each test.~ Test Plan: See next PRs
This is a very early version of the next-dev test runner. I'm opening this early to get thoughts from folks re: the direction of the design and implementation. Fixes vercel/turborepo#204 Currently it: * Discovers integration test fixtures from the filesystem. Right now these are expected to be single files that get bundled and will eventually include assertions. This is powered by the test-generator crate, which allows us not to have to manually enumerate each case. We could consider using this for the node-file-trace tests as well. * Starts the dev server on a free port and opens a headless browser to its root. The browser control is implemented with the https://crates.io/crates/chromiumoxide crate, which expects Chrome or Chromium to already be available. Eventually it will: * [x] Implement a minimal test environment loaded in the browser so that assertions can be run there from bundled code. * [x] Report back the results of these assertions to rust, where we can pass/fail cargo tests with those results. In the future it could: * Possibly include snapshot-style tests to assert on transformed results. This could be in the form of fixture directories instead of files cc @jridgewell * Support expressing special configuration of turbopack in a fixture, possibly as another file in the fixture directory. * [x] ~Possibly support distributing tests to a pool of open browsers instead of opening and closing for each test.~ Test Plan: See next PRs
Should fix #195
It still uses
filesytem.Split
but just to get the directory name to create it if it doesn't exist.It opens the file with
os.OpenFile
and set the file permissions there instead of after copying.It removes the file if
io.Copy
returns an error.It doesn't need error handling on
toFile.Close
as it only returns an error if it's called multiple times.