test threads for cargo (rust)
I need to make sure that cargo runs my tests sequentially by passing --test-threads=1 to the test runner executable.
Locally I can do this using
cargo test -- --test-threads=1
However, it seems having that line in my test_script section doesn't work. It seems the double-dash is ignored.
How do I make sure that above command is run correctly?
Here is the link to my appveyor.yml file
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

1 Posted by Ilya Finkelshte... on 16 May, 2018 01:54 AM
Sorry for confusion. While PowerShell blocks runs as a single script, CMD runs line-by-line. Workaround is to wrap the whole script in
.cmdfile and run that file.2 Posted by spam.wax on 16 May, 2018 02:45 AM
I'm not sure how to do this exactly!
Do I have to create a .CMD in my repo and somehow call it from yml script?
What would be the content of that file to ensure sequential run and how do
I call it from yml?
3 Posted by Ilya Finkelshte... on 16 May, 2018 02:55 AM
Yes, you can check-in
.cmdin repo. But in your case indeed it is simple to use one-liner like this:Let us know if this works for you.
4 Posted by spam.wax on 16 May, 2018 03:07 AM
I already had that line in
test_scriptsection.I even put the whole thing in one line as suggested but still tests are run concurrently.
my current appveyor.yml
5 Posted by Ilya Finkelshte... on 16 May, 2018 06:25 AM
Your
appveyor.yml(at least at the moment), uses- shprefix for that command, which makes sense only for Linux builds (if you chooseUbuntuimage). But you probably already realized that.I do not believe that double-dash is ignored. You can RDP to build VM and run command manually and you will probably see the same result.
I am not Rust expect by any means, but here and here people say that
--test-threads=1specifies number of addition thread, not total number of threads.I would try to understand the difference between local run and AppVeyor run.
Do you have the same errors locally if you do not specify
--test-threads=1and they disappear if you specify that?Do you have the same Rust version locally and on AppVeyor?
How many CPU cores you have locally? AppVeyor VM has 2. Number of CPU cores can affect parallelism.
6 Posted by spam.wax on 16 May, 2018 06:37 AM
Thanks for your response
Yea, I had been changing it from
cmdtopstopwshand toshjust to get the thing working!That's correct, the main thread is in charge of running each new thread assigned to a specific test.
I do not get any error when
--test-threads=1locally. Not having it actually causes errors which are different every time. The web-server mocker in tests only listens on port 1234 and if multiple tests are run it will cause issue since it has a fixed response.Yes, I have tested it with multiple versions as well
I have 6 cores at my local machine
How can I echo the command that
test_scriptactually calls/runs?And in what env./shell the .yml runs/launches its command?
7 Posted by Ilya Finkelshte... on 17 May, 2018 03:53 AM
CMD is being called by build agent (.NET program) using native interop calls. What you see in the line before command like here is exact echo of what is going to be called.
RDP to build VM and run command manually so you can rule out the fact that command is being called by build agent. Please note that RDP session does not have the same environment variables as build session, so you need to re-create environment variables which are critical for this command execution.
Let us know what you found.
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:28 AM.