-
Notifications
You must be signed in to change notification settings - Fork 693
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
fix: make cargo test testnet
work on windows
#5937
base: develop
Are you sure you want to change the base?
fix: make cargo test testnet
work on windows
#5937
Conversation
…t run on windows. Now 'cargo test testnet' ends succesfully on windows os, stacks-network#5930
What do I have to setup/install in order to try? |
If you mean locally on your machine: Prerequisites
Validation:
|
Thanks! I can't reproduce this on windows 11 arm64:
@fdefelici, if your setup differs, let me know how to try it on a clean box. I can reset easily. |
i was able to get a VM with windows running on x64 to test this - but ran into a strange error that i can't reproduce on other systems. edit: it definitely seems to be a problem with the tool on windows. linux reports the sha256 of your branch correctly. i'll dig into it a bit more, see if i did something wrong here. |
It is the "correct" behaviour by now. Anyhow considering that the problem is due to file end-of-line, another possibility is just edit the eol from CLRF to LF for the following files:
|
The only difference I have is the target architecture. I have |
@fdefelici, for the build output see: https://gist.github.com/moodmosaic/4a9022de3bd5ef8aa1ab6b3e0ac15a3c |
Ok thanks. the problem is clear. It Is due the winapi crate that has not support for arm64. As far that crate is obsolete we could think to migrate to the windows crate that should have better support for arm64. Anyhow Better to split in a specific issue/pr. So, by now another prerequisite is that the architetture that must be x86 family Basically the configuration that @wileyj is testing. |
confirmed - it was user error. i set the config value as |
after fixing the gitconfig, the tests on this branch all pass. |
Tracked this issue here #5947 |
Tested successfully on an x64 system. I will try with an arm64 asap. |
OK, I got this to work on arm64 — specifically on a clean Windows 11 arm64 VM. This time I used only PortableGit and Skeeto's w64devkit. No MSVC, no Visual Studio, no Windows SDKs, no system-wide installs. Notes:
|
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.
Tested on Windows ARM64 with w64devkit. Left a small nit.
echo ] | ||
) | ||
"#; | ||
let path = "/tmp/test-get-unconfirmed-commits.bat"; |
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.
This works in Git Bash but might not work in PowerShell, perhaps a more portable way could be
let path = "/tmp/test-get-unconfirmed-commits.bat"; | |
let path = std::env::temp_dir().join("test-get-unconfirmed-commits.bat"); |
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.
Yes this should be the right way. I was aware of that but didn't fix it here, because in all our codebase all tests doing filesystem I/O use /tmp
as root folder (and if the folder doesn't exists it is automatically created).
Infact if you run cargo test testnet
from both cmd
or powershell
the tests should ends succesfully.
For sure this need to be improved, but I would prefer doing it in more general fashion in this issue #5932.
So, if you agree, we can leave it as it is (to keep the tests homogeneous for now), and face it in the dedicated issue.
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.
Yeah... AFAICT, the test runs the script, parses JSON output, and checks values. But the batch file won't run directly in PowerShell (unless they are prefixed with e.g. .\script.bat
?).
Perhaps the safest is to invoke it explicitly via cmd.exe
, e.g.:
let output = Command::new("cmd")
.args(["/C", path])
.output()
.expect("Failed to execute batch script");
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.
Just to be sure and clear my understanding: did you tried running from powershell and you got some error?
I'm just asking for confirmation, because I tried to run from powershell these commands with success:
- cargo run testnet
- C:\tmp\test-get-unconfirmed-commits.bat
- /tmp/test-get-unconfirmed-commits.bat
The only way I'm able to get an error (the one you describe) is when running the bat file with relative path.
So doing this gives error:
cd tmp
test-get-unconfirmed-commits.bat
//I got some red error and then this hint
Suggestion [3,General]: The command test-get-unconfirmed-commits.bat was not found, but it exists in the current path. By default, Windows PowerShell does not load commands from the current path. If you trust the command, type ".\test-get-unconfirmed-commits.bat" instead. For more information, see "get-help about_Command_Precedence".
So by the fact we run it in the test with absolute path, we shouldn't have any error.
Instead if you got error, please share it, so I can collect it for later analysis (hopefully even the powershell version), and eventually I can apply the patch your proposing.
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.
running cargo test testnet
worked both on cmd and powershell on my end
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.
LGTM (tested on x64 windows 11)
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.
Tested on Win11 x64, works great. Just left a comment for a documentation nit
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.
This all looks fine to me 👍
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #5937 +/- ##
===========================================
+ Coverage 82.88% 84.51% +1.63%
===========================================
Files 522 522
Lines 382715 381322 -1393
Branches 323 323
===========================================
+ Hits 317232 322293 +5061
+ Misses 65475 59021 -6454
Partials 8 8
... and 104 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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.
Definitely improves support for Windows, working even on the bare-bones setup, as pointed out in #5937 (comment). Looks good to me.
Description
this patch makes
cargo test testnet
command work properly on windows.Addressed:
Applicable issues
Additional info (benefits, drawbacks, caveats)
Checklist
docs/rpc/openapi.yaml
andrpc-endpoints.md
for v2 endpoints,event-dispatcher.md
for new events)clarity-benchmarking
repobitcoin-tests.yml