tag:help.appveyor.com,2012-11-13:/discussions/questions/20515-test-threads-for-cargo-rustAppVeyor: Discussion 2018-08-25T02:28:50Ztag:help.appveyor.com,2012-11-13:Comment/452883752018-05-16T01:54:00Z2018-05-16T01:54:00Ztest threads for cargo (rust)<div><p>Sorry for confusion. While PowerShell blocks runs as a single script, CMD runs line-by-line. Workaround is to wrap the <a href="https://github.com/spamwax/alfred-workflow/blob/a3d848d8cf233477f477f36ba76d07ae1ef11e30/appveyor.yml#L39-L41">whole script</a> in <code>.cmd</code> file and run that file.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/452883752018-05-16T02:45:55Z2018-05-16T02:45:55Ztest threads for cargo (rust)<div><p>I'm not sure how to do this exactly!<br>
Do I have to create a .CMD in my repo and somehow call it from yml script?<br>
What would be the content of that file to ensure sequential run and how do<br>
I call it from yml?</p></div>spam.waxtag:help.appveyor.com,2012-11-13:Comment/452883752018-05-16T02:55:10Z2018-05-16T02:55:10Ztest threads for cargo (rust)<div><p>Yes, you can check-in <code>.cmd</code> in repo. But in your case indeed it is simple to use one-liner like this:</p>
<pre>
<code> - if [%APPVEYOR_REPO_TAG%]==[false] (cargo test --target %TARGET% --lib -- --test-threads=1)</code>
</pre>
<p>Let us know if this works for you.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/452883752018-05-16T03:07:01Z2018-05-16T03:07:49Ztest threads for cargo (rust)<div><p>I already had that line in <code>test_script</code> section.<br>
I even put the whole thing in one line as suggested but still tests are run concurrently.</p>
<p>my current <a href="https://github.com/spamwax/alfred-workflow/blob/master/appveyor.yml">appveyor.yml</a></p></div>spam.waxtag:help.appveyor.com,2012-11-13:Comment/452883752018-05-16T06:25:48Z2018-05-16T06:25:48Ztest threads for cargo (rust)<div><p>Your <code>appveyor.yml</code> (at least at the moment), uses <code>- sh</code> prefix for that command, which makes sense only for Linux builds (if you choose <code>Ubuntu</code> image). But you probably already realized that.</p>
<p>I do not believe that double-dash is ignored. You can <a href="https://www.appveyor.com/docs/how-to/rdp-to-build-worker/">RDP</a> to build VM and run command manually and you will probably see the same result.</p>
<p>I am not Rust expect by any means, but <a href="https://stackoverflow.com/questions/43458194/is-there-any-way-to-tell-cargo-to-run-its-tests-on-the-main-thread">here</a> and <a href="https://stackoverflow.com/questions/44947914/how-to-limit-the-number-of-test-threads-in-cargo-toml">here</a> people say that <code>--test-threads=1</code> specifies number of <strong>addition</strong> thread, not total number of threads.</p>
<p>I would try to understand the difference between local run and AppVeyor run.</p>
<ul>
<li>
<p>Do you have the same errors locally if you do not specify <code>--test-threads=1</code> and they disappear if you specify that?</p>
</li>
<li>
<p>Do you have the same Rust version locally and on AppVeyor?</p>
</li>
<li>
<p>How many CPU cores you have locally? AppVeyor VM has 2. Number of CPU cores can affect parallelism.</p>
</li>
</ul></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/452883752018-05-16T06:37:46Z2018-05-16T06:39:50Ztest threads for cargo (rust)<div><p>Thanks for your response</p>
<p>Yea, I had been changing it from <code>cmd</code> to <code>ps</code> to <code>pwsh</code> and to <code>sh</code> just to get the thing working!<br>
That's correct, the main thread is in charge of running each new thread assigned to a specific test.</p>
<ul>
<li>
<p>I do not get any error when <code>--test-threads=1</code> locally. 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.</p>
</li>
<li>
<p>Yes, I have tested it with multiple versions as well</p>
</li>
<li>
<p>I have 6 cores at my local machine</p>
</li>
</ul>
<p>How can I echo the command that <code>test_script</code> actually calls/runs?</p>
<p>And in what env./shell the .yml runs/launches its command?</p></div>spam.waxtag:help.appveyor.com,2012-11-13:Comment/452883752018-05-17T03:53:30Z2018-05-17T03:53:30Ztest threads for cargo (rust)<div><p>CMD is being called by build agent (.NET program) using native interop calls. What you see in the line before command like <a href="https://ci.appveyor.com/project/spamwax/alfred-workflow/build/1.0.16/job/f5lxc138f2kw9b7m#L37">here</a> is exact echo of what is going to be called.</p>
<p><a href="https://www.appveyor.com/docs/how-to/rdp-to-build-worker/">RDP</a> 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.</p>
<p>Let us know what you found.</p></div>Ilya Finkelshteyn