Robocopy does not report errors when run on AppVeyor
I create a post on GitHub community before finding this link.
Essentially, my project is a wrapper for RoboCopy. It has a ‘live updater’ that shows file stats live by intercepting t he Std:out of the robocopy process.
The unit tests that are failing because the live update results do not match robocopy’s final tally.
But these unit tests pass just fine when run locally. The unit test is also working properly, since robocopy itself shows 1 file as failing, which is intended in the test.
The issue here is that when GitHub commits tell the tests to run automatically on AppVeyor, the tests fail because robocopy is not reporting errors to it’s std:out, meaning the live results never catch that an error occurred, because one was never recorded into the log.
This issue appears to be exclusive to when running robocopy on AppVeyor
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
Support Staff 1 Posted by Feodor Fitsner on 09 Mar, 2022 06:23 PM
Hi Rob,
The process of collecting output from the process programmatically is different from that in Windows console. You collect the output using event handlers of
Process
class. It is triggered on a new line only. AppVeyor uses the same approach, but it constantly reads an output stream. So, there could be some quirks with double redirect, like buffering issues. It's hard to tell you what's wrong and where without digging into your code. Maybe you can do a simple repro, like a small console program or test with Process class calling some robocopy command and catching the output.2 Posted by Rob on 09 Mar, 2022 06:57 PM
So that is where it gets odd though. The entire log being written into the test results is captured using the same event.
We subscribe to the process events, start the process, wait for it to exit. As the process outputs the data, it gets added to a list<string> object.
That list is then written into the test log at the end with a ForEach—loop.
The log is identical between local and AppVeyor, other than the fact that robocopy is not outputting the error lines in the AppVeyor log. That is the actual issue, since the project relies on all items being written to the log.
So AppVeyor is doing it’s job fine, no arguments here. The issue is whatever executable of robocopy AppVeyor has is not writing errors into its std:out.
I’m on mobile, so can’t copy-paste the log here, but it’s available in the link and in the AppVeyor logs, which were also linked (atleast in the GHC thread)
Support Staff 3 Posted by Feodor Fitsner on 09 Mar, 2022 08:33 PM
OK, can you give me a sample of robocopy command, its expected output and actual output on AppVeyor?
4 Posted by Rob on 10 Mar, 2022 01:46 AM
I would've replied hours ago, but I couldn't get appveyor to build my test repo that displays the issue. Turns out VS was not providing a reference in the CSProj file to a nuget package that was being downloaded....But now that its working, I can reply:
The issue at hand is that RoboCopy wasn't generating an error in its std:out, sometimes?
Here is the link to the new repo that I finally got working that displays the issue:
https://github.com/RFBomb/RoboCopyErrorTesting/tree/master/RoboCopy...
In it I have two tests. Everything related to robocopy is run identical, the only thing that changes is the source folder as far as robocopy is concerned.
here are the test results, not sure if you can see them.
https://ci.appveyor.com/project/RFBomb/robocopyerrortesting/build/t...
RoboCopy Command:
Expected Output:According to my repo, the test above works fine.
The test we have in our other repo though is simulating a file that is locked by another process. That test fails due to no error being reported.
Same RoboCommand, except have it point at a valid source and destination.
Use File.Open() to lock a file, run robocopy, unlock the file, print results.
Expected Results:
Appveyor Results:
I've condensed both logs for brevity, showing only the files immediately before and after the expected error. The file marked as 'older' is the file that is locked and unable to be written to by robocopy. As you can see, the error is reported locally, but not on appveyor.
Since the source not existing test reported an error, I have no idea what the issue could be.