-
Notifications
You must be signed in to change notification settings - Fork 16
[WIP] Add STM tests for Sys module #129
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
Conversation
bf90b9e to
d12f0e8
Compare
497d51a to
b918322
Compare
|
I've taken a first quick pass over the code. There's duplicate code:
There may be other occurrences, so take it as an exercise to review your own code critically and see if you can spot other occurrences or possibilities to simplify, shorten, and reuse. Since this is a In the harder end, the underlying generators could be adjusted:
Finally, as of last night we now have Windows CI tests. This means some of the Unix-specific |
c302f17 to
0ccbf63
Compare
|
I found out that the CI workflow will not run when there are conflicts:
So I guess it is easiest to rebase on the latest |
760998b to
d1ba3cb
Compare
src/sys/stm_tests.ml
Outdated
| (* | "Win32" -> | ||
| ignore (Sys.command ( | ||
| "powershell -Command \"Remove-Item -Path " ^ (static_path / "sandbox_root") ^ " -Recurse -Force -ErrorAction Ignore \" | ||
| & mkdir " ^ (static_path / "sandbox_root"))) *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can safely remove these commented out lines now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the CI clean everything after a run? Imagine if a test crashes (with an assert false, for example), the filesys will not be removed. I can remove it locally, but does the CI automatically reset things?
a629d12 to
4f584e4
Compare
|
It seems there is a problem with Windows giving different error messages in For example, |
|
There's also a problem with |
I think the problem here is that on Windows, a See https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mkdir |
|
The current error case in (s = (p complete_path) ^ ": No such file or directory" && not (mem_model fs path)) ||As I understand it, this will only be true when |
Yes, of course, you are right! I fix that mistake. |
|
Can I conclude that on Windows, there is no separation between |
|
I'm largely clueless about Windows unfortunately. Overall, I would expect that the error messages in It is good that you are doing experiments! 👍 I suggest first getting something to work on Windows by experiments as you are doing now - and then afterwards we can consider cleaning up the code if it is needed. |
|
I think the next problem is that I believe that |
|
I did some tests on my PC. The two things seem to behave the same, except touching an existing dir_name, where windows complain. I miss a case in the touch postcond. If I get back n = 1 (the file can't be created), I check either:
But it can also fail if the full path ( with the file's name) already exists. |
This could allow for some more sharing, when k is already mapped to v
Use Sys.mkdir instead of Sys.command "mkdir"... to create the sandbox to avoid discrepancies between OSes This also allows to set safer permissions, by restricting access to the sandbox to the user running the test
Use Filename.quote to ensure that the sandbox is properly quoted before invoking Sys.command On windows, use the simple 'rd' command instead of calling powershell (which would require double-quoting, we should probably avoid that) On unix, use 'rm -r' instead of 'rm -rf' since, at the moment, '-f' should not be required
Since the generated permissions were always the same and that it is probably an aspect that is quite different between Unix and Windows, remove them for now
Change the implementation of Touch so that the behaviours are similar on Unix and Windows: by using an 'echo . > file' on all platforms, it will uniformly fail when Touch is attempted on an existing directory
Choose a better name for the command that makes a new regular file Use `Out_channel` instead of a shell command to create such a file Take into account the fact that the creation can fail in postcond, which makes Mkfile fairly similar to Mkdir
Instead of using the full absolute path, which makes the logs with counter-examples harder to read, use a simple relative path for the sandbox Change its name from `sandbox` to `_sandbox`, to follow the common usage for generated directories (such as `_build` etc.)
The missing `close_process_in` did leave a zombie around for the duration of the test
|
This CI run was all green, so I've removed the two commits focusing tests on |
|
I just spotted some left-over commented-out code which f932eda removes. |
|
We've been over this repeatedly - so the time has come: merging 😃 |
|
Even if that PR is already merged, it’s still the best place to store the fact that I could reproduce the behaviour of two simultaneous |
|
Another follow-up: I wrote a small test to track down the weird behaviour we saw where a |
|
Interesting! val rmdir : string -> unit
Remove an empty directory.
Since 4.12.0 |
|
All the functions in |
|
According to this article and the detailed PhD thesis behind, POSIX doesn’t mandate directory operations to be atomic:
|
|
Good detective work, sir! 👍 |
|
As the case of having an observable intermediate state during the removal of a directory cropped up again in a CI run (see that comment), I’m wondering whether we should reimplement |
No description provided.