Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NCrunch reload and rebuild does not work
abelb
#1 Posted : Friday, September 12, 2014 6:04:15 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
Often, when I click Reload and Rebuild in the context menu of a project, it does nothing. The status is "Not Built" (after a failed build). Rightclick, select "Reload and rebuild selected component", then nothing happens.

Other tricks, like changing the project settings, either in NCrunch settings or in the csproj itself, have no effect.

It seems to happen randomly, but one way that was always reproducible was:

  • open your solution
  • let NCrunch build, until it fails (say, a reference in the csproj is not found)
  • unload the project
  • open the csproj file for editing
  • change something (say, you fix the reference)
  • reload the csproj file into the solution
  • expected: rebuild (because there's a project change), but nothing happens
  • select "Reload and rebuild"
  • expected: rebuild, but nothing happens, text stays on "Not Built"


Sometimes, but not always, some five minutes later it suddenly decides to build (the text shows "First time build"). It then stops, showing "Not Build", without any error. This repeats every 5-10 minutes if you let it.

Solution: close Visual Studio, reopen it again. But that is not a solution, of course.

Any ideas, or is this a clear case of bug? It feels like one to me.

Sorry, not a registered user (yet), I'm testing the product, and I'm impressed by its features, but so far, it seems to give me more headaches instead, which is a pity as I expect a lot from it.
Remco
#2 Posted : Friday, September 12, 2014 10:06:28 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue. It seems to me like something is going very wrong internally. After you've managed to stall the engine in this way, would you be able to try submitting a bug report? The log file in the bug report may give some important clues as to what kind of state the engine has found itself in.
abelb
#3 Posted : Saturday, September 13, 2014 12:09:36 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
I submitted a report, but didn't get the chance to fill in any user details and now I have no idea where I can find this bug report and/or track its status. I gave it a title something like "NCrunch halts at loading coverage data at 83%" (which is not the same as this, but possibly related). It froze for at least 24 hours.

I will also send in a report about this particular behavior. I noted that it also locks DLL files, just like the other bug report. In addition, after closing all instances of Visual Studio, those files are still locked (!). Finally, to solve it, I need to kill every "nCrunch.TaskRunner40.x86.exe" (and there are 17 of them) from the task manager.

Strange, because according to online reviews, one of the good things about NCrunch is that it does not block access to built DLL files. I thought it runs in isolation somehow.
Remco
#4 Posted : Saturday, September 13, 2014 10:42:59 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks for sending through the report. The report shows that the engine experienced a problem when trying to read data from your NCrunch cache. Try deleting the solution_NCrunch_v2 directory to see if this makes any difference.

Much of the behaviour you've described is not at all normal. Do you have any projects in your solution with this setting turned off? http://www.ncrunch.net/documentation/reference_project-configuration_include-static-references-in-workspace.

Also, do you have any integration tests that make use of absolute file paths references? Any cross process tests or code that builds its own application domains perhaps?
Remco
#5 Posted : Saturday, September 13, 2014 10:45:26 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Something else I noticed in the log is that your build process seems to be attempting some kind of test generation step. Can you share any more details about this? I'm wondering if NCrunch's handling of this build step may also be causing some strange things to happen.
abelb
#6 Posted : Saturday, September 13, 2014 11:43:38 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
Hi Remco,

Thanks for getting back at me. To answer your questions:

- No, we do not use absolute path references (the exception being if a toolset is typically under Program Files or something the like, in which case we use a global MSBuild macro, such as $(MSBuildExtensionsPath32). These seem to work fine with NCrunch
- Yes, we do have our tests auto-generated, at least most of them. One possible (additional) reason that thinks may be going wrong is because recently we had a bug with the auto-generation of the tests, which may have made things worse. I recently discovered that MSBuild itself does not close correctly after this (even with NCrunch disabled). Currently I am fixing this auto-generation bug.
- The auto-generation is done as a pre-build step and the output is part of a (one of many) test projects in the solution. This worked fine with the NUnit and Resharper test explorers, as they browse the tests *after* compiling and the compiled binaries contain the correct test metadata (as do the actual source files).

Still, I don't think it is correct behavior that NCrunch hangs, regardless what happens. At least it should have some way to cancel the process (like you can cancel a build). Maybe there is such option, I just haven't found it. Btw, I thought I share the screenshot:

Hanging at 83%

I will try to clean the temp files and see what happens. I will also test the originally described behavior in a different solution, see if it is reproducible in simpler solutions.
abelb
#7 Posted : Saturday, September 13, 2014 11:44:39 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
Hmm, this forum has an image button, but if you use it, it does not work???

Fixed, needed to set the imgur image, not the imgur page in the url
Remco
#8 Posted : Sunday, September 14, 2014 12:04:21 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Builds themselves shouldn't normally hang unless there is a custom task or step within the build that does this. Unfortunately introducing an option to allow you to terminate a hung build isn't really a solution for NCrunch, as it builds so frequently that this would quickly become annoying/unmanageable. It IS possible to terminate builds simply by ending the task using task manager. NCrunch detects when tasks have been terminated and will align its state accordingly.

I think the best plan of action would be to disable the test generation for NCrunch builds. Likely you won't want this to run as part of your NCrunch build - it will slow down the build and will manipulate the contents of files in the workspace. It's hard to tell what kind of effects this could have on the engine - probably it will depend upon the nature of the generation and how it works. Better to just shut it off and generate the tests in your foreground build. NCrunch will then detect the changes from the auto generation when you build, and will itself rebuild the projects accordingly in the background.

To disable the generation for NCrunch, just specify a build override inside your project/targets file. NCrunch does also let you disable pre/post build events but these config settings will only work for the command line invocations and not for the pre/post build targets.
Remco
#9 Posted : Sunday, September 14, 2014 12:05:06 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
I just also wanted to mention to make sure your IDE is closed when you clear up the temp files. This will help to ensure you get a clean slate.
abelb
#10 Posted : Sunday, September 14, 2014 12:13:59 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
I was thinking about your proposal: exclude it from the NCrunch build, but that wouldn't help, as the auto-generated test project relies on the rest of the project. If I don't rebuild it, I don't test the changes in the project.

However, the part of it that is autogenerated, is a pre-build event using an MSBuild task. I changed the name of this task from BeforeBuild to BeforeRebuild. This helped for local builds vs. rebuilds. Now I am looking for a property that I can use, something like Condition="!$(NCrunchBuild)", which allows me to do the prebuild step only when the build is triggered by something other than NCrunch.

About the non-responsive NCrunch on 83%. Now that the build is successful, it still hangs, but it does first go over many tests (but not all, some 800 tests of approx. 9,000 tests). Then it stalls forever on 83% again (as in the screenshot). However, I found a way to "Cancel" the NCrunch build: simply disable NCrunch. It took about two minutes, but then NCrunch was disabled and the tasks were gone from task manager.

One small bug though on disabling: the text in the screen, "Loading code coverage data (83%)", remains in the screen. The animated circle changes to grey, and the text in the caption changes to the correct "NCrunch engine is disabled".

Managed to get the image BBCode working (I didn't point to the actual image, but to a page).

Step 1, after a restart, successful rebuild, I see variants of this:
Step 1

Step 2, it freezes at some point, indefinitely, NCrunch tasks remain in task manager, main problem is that it is unclear what project the "1 project failed to build" points to, would be nice if it said so in the log (and properly canceled the rest of the build).
Step 2

Step 3, after disabling NCrunch, it looks like this:
Step 3
abelb
#11 Posted : Sunday, September 14, 2014 12:33:37 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
In addition to the above, I checked the documentation of NCrunch here: http://www.ncrunch.net/d...re-or-post-build-events and found that the setting for this project has running post- and pre-build events switched off. We use a standard way of running the post- and pre-build events, essentiall, by name, which is recognized by MSBuild. It looks like it is not recognized by NCrunch. Example:

Code:
<Target Name="BeforeReBuild">
  <Delete Files="@(Compile)" />
  <GenerateTests CompileFiles="@(Compile)" />
</Target>


Same is true for Name="BeforeBuild". Both are recognized by MSBuild, but (seems like) not by NCrunch. A bug, or am I doing something wrong?
abelb
#12 Posted : Sunday, September 14, 2014 2:57:50 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
The good news: I think I got it running, at least somewhat. After fixing the pre-build steps and removing another step (in two linked projects there as an ILMerge step, which ran always, and I changed it to "only when certain files were updated", and after removing the "NCrunch_MySolution" directory, it built correctly.

It started to run the tests and show progress. It also showed that it built everything correctly (I mean: no build errrors). However, it runs excruciatingly slow (all the 14 NCrunch task runners combined take less than 0.5% CPU time).

The bad news: after I changed the Threading settings during it running the tests, there was still something strange: the progress was gone in the NCrunch Tests window and in the NCrunch Metrics window. In the NCrunch Risk/Progress window, however, a reddish bar showed progress.

The only thing I see is red circle with, what I assume, the failing tests in it. I can see the "xxx tests are queued" changing (getting lower). But why is it stalling again on "Loading code coverage data (83%)"?

Here's a screenshot. I submitted a bug report, in case it helps (added your name and the thread id to the title).

Strange screen

And after it finished, this is what it shows, which is slightly better than before, but still useless because I cannot get to the tests overview. It shows the same in the Metrics window. And all coverage buttons in the code are black, instead of green/red:
No overview
Remco
#13 Posted : Monday, September 15, 2014 12:15:31 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
The 83% issue you're experiencing is entirely related to corruption of the NCrunch .cache file. It isn't clear to me why this file is being corrupted for you. As you've described, clearing out the cache temporarily resolves the problem, but it simply comes back again. Most likely there is something to do with the structure of your tests data that is surfacing an issue in there somewhere. I'm wondering if you may be interested in trying the build below. This build contains several fixes intended to improve NCrunch's handling of cache file corruption. It should be able to work around any corruption issues you encounter (now or in future) and may also give some clues as to where the corrupt data is originating from.

http://downloads.ncrunch.net/NCrunch_Console_2.10.0.3.msi
http://downloads.ncrunch.net/NCrunch_Console_2.10.0.3.zip
http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.10.0.3.msi
http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.10.0.3.zip
http://downloads.ncrunch.net/NCrunch_VS2008_2.10.0.3.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.10.0.3.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.10.0.3.zip
http://downloads.ncrunch.net/NCrunch_VS2012_2.10.0.3.msi
http://downloads.ncrunch.net/NCrunch_VS2012_2.10.0.3.zip
http://downloads.ncrunch.net/NCrunch_VS2013_2.10.0.3.msi
http://downloads.ncrunch.net/NCrunch_VS2013_2.10.0.3.zip

If you want to override or suppress a build target using NCrunch, you need to use the $(NCrunch) environment variable explained here - http://www.ncrunch.net/documentation/troubleshooting_ncrunch-specific-overrides.
1 user thanked Remco for this useful post.
abelb on 9/28/2014(UTC)
abelb
#14 Posted : Thursday, September 25, 2014 2:42:09 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
Sorry for this late reply, I was out of the country for a couple of days. However, meanwhile I tweaked the solution and the NCrunch configuration a bit further. It appears to me that the dependency on about 19,000 small files was a main cause of issues. I think that NCrunch copied all those files, possibly even for each isolated testrun. Even if not, keeping track of that many files for changes may have been another cause of issues.

I reconfigured the test scenarios in such a way that the files are in an absolute location, yet relative to the solution's root. The autogenerated tests will set this location automatically and do a chdir prior to running the tests, which deals with the relative dependencies.

I loose the auto-rerun of tests if I change the underlying test files (mainly XML files), which form the core of the testsets (the NUnit tests themselves are just a shim around these XML testsets, a so-called test-harness).

Another cause may have been the problematic moment of recompilation. Typically, the autogenerated tests where rebuild on every build. After I changed it to rebuild only on a real *rebuild*, it helped a lot, but made recreating the testsets more problematic, as a rebuild takes ~10 minutes and a build just 50 seconds.

Your hint of using the NCrunch variable/macro for the MSBuild configuration helped with this. Now the tests are only build on a normal build, but not when NCrunch rebuilds them. NCrunch can use the prebuild binaries and does so quite fine.

The end result is not ideal, but it does give me a better way of testing and it gives me a way to use almost, but not all of NCrunch's features.

Note: I have not yet tried your updates above, as I was too much in a hurry to get certain features running. I assume they are now part of the new version anyway, which I will install shortly. If I see differences in behavior, I will let you know.
1 user thanked abelb for this useful post.
Remco on 9/25/2014(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.092 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download