-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
run time depends significantly on the amount of text printed by the command under test #180
Comments
Are there a large number of expectations (
Detailed data (e.g., number of seconds) is not necessary, but a simple sample code here would be appreciate to make it easier to understand. |
I prepared a test repo: https://gitlab.com/amarcine/test-long-output I made my checks on bash 5.0.3 if that might be significant. My results were:
I am not only surprised by the fact that the run time depends so much on the amount of text printed, but also that making no checks gives much longer run time - 4 times in my case. I understand that shellspec doesn't expect commands producing lots of output, but its behaviour without checks is rather strange. I could accept that doing many complicated checks on large text output could increase the run time, but as you see from the test cases there are essentially no checks. |
Thank you for the test repository. Regardless of whether you want to check the output or not, it will take some time because the output contents are loaded into memory. However, it is strange that it takes longer not to check. I suspected the file cache and reversed the execution order, but it didn't seem to change. Also, I changed to dash instead of bash, but it will take longer not to check. This needs to be investigated. The output is read line by line by the shell with the By change to read output content when checking, It can improve the speed when not checked. However, in general we would check the output. I don't think it's very effective in a realistic test, but in your case, do you often not check the output? |
If the output is not checked, a warning will be displayed along with the output contents. Since all the output contents are included in the report protocol, I can assume that this is causing the slowdown. We need to to add the ability to suppress warnings (#122), or to improve the warning content and reporting protocol. |
My usual use case - integration testsIn my case I would most often not check the output. I use it for integration tests of a program and associated library which processes high energy physics data. So the program makes some calculations, the results of which are streamed in binary or ASCII files, but never to the stdout. The output is used there only to see which steps were passed, what DB entries were used etc. So as more or less verbose progress and debug messages. The output is most useful to understand when something fails either getting the answer in the output itself or comparing the output from a successful and failed runs. Therefore I need the output stored along with test results - hence the improvements I asked earlier regarding the JUnit xml - but usually I do not assert the output content. My understanding of the reasons for slowness and possible solutionsOK, so if I understand correctly the reason why
Ultimate solution - change of the way how output is loadedBoth cases could be made faster for large output moving from Btw how do you manage the choice of tools depending on their availability or requests - do you make a choice when the tool is used or in some initialization phase of shellspec to set once and use many times? It is probably a stupid question, so sorry, but for an object oriented software I would expect initialization phase to compose the behaviour, while for procedure oriented software, as I understand Partial solution - speeding up when no assertions are doneIrrespective of But I do have a question - what happens for the JUnit report? - supposing the warnings are gone but I still want the full output in JUnit xml, will this again use |
I will make improvements due to performance issues and shells cannot handle binary data, but ShellSpec is a unit testing framework. I don't deny that you can use it for integration testing, but it is not a high priority and there will be other omissions to consider. If there are conflicting requirements, use as a unit testing will be given priority. The performance problem of this issue will be solved by not reading unnecessary output. To this end, I plan to make the following improvements.
The
Changing And, I think if the data is large, we will want to compare it with the correct file. I mean, #138. (I'm sorry I've been putting off this PR. I haven't considered it enough yet.) For small data, Also, if you really want to use shellspec_readfile() {
eval "$1=\$(cat \"\$2\"; echo _); $1=\${$1%_}"
}
I don't understand the meaning of the question. I think it is common for any command to change its behavior with configuration files, options, environment variables, etc. It also doesn't even matter if it is object-oriented or not.
In the case of the JUnit formatter, the contents of the stdout and stderr are not included in the reporting protocol, so they are not directly related to this issue. However, it may already be slow for another reason. This will be addressed in another issue. |
@AntoniMarcinek If you have ideas about integration testing, please post them here (#187). |
Thanks for all the explanations! Sure, it is clear that ShellSpec prioritizes unit testing. The 2 improvements you mention look very reasonable. While comparing large output to file is useful in itself, using string matchers is also useful. In my use case there is a lot of text printed from other parts of the system than the specific subject of my test. So while I would check file equality for some specific files produced by the executable, I wouldn't really do it on stdout/err. If you would improve performance using Thanks for the tip with overriding functions in the helper. Looks like this pretty much removes any need for an option to choose between Please forget the question "how do you manage the choice of tools...". In the test project one can switch off the junit in Regarding the integration tests discussion, should I repeat what is already in the issue we iterated several times for the sake of completeness/clarity or you want me to post any new ideas I have? |
The number of warning lines has been reduced and the output is not read when it is not needed. I believe these fixes (#188) resolved the direct problem of this Issue.
If you have something else you want to write. |
Thank you! Indeed it seems to fix the problem. I will iterate on the integration tests discussion some time later. |
Depending on settings the program which I am testing with shellspec can produce 100 lines of output to stdout, 1000 lines or 10000 lines. The run time of the program itself does not change significantly, but once it is wrapped in shellspec test it takes 9s, 20s and 300s respectively. @ko1nksm do you understand this effect? If it is not obvious to you, I will produce a demonstration.
The text was updated successfully, but these errors were encountered: