How to check NAnt version inside a NAnt script to display error?
For example my NAnt script works with NAnt version +0.92, so I need to display error if lesser version is being used by the user.
There is a default property called nant.version which you can check against. This is now deprecated, you will see the rather verbose replacement in the warning message.
I don't know an easy way to enforce a minimum version check, but you could make something using the version functions, or write your own task (it's not hard, using the Version class in dot net to compare them).
Related
I am attempting to run unit tests from Eclipse on C++ code. My Eclipse is Mars.2 Release (4.5.2). I originally downloaded the Java Developer's version, but I've installed C/C++ plugins. I wrote a simple class and then a boost unit test for that class. I can compile the code both in Eclipse and on the command line to get an executable. If I run the executable on the command line, I get this output
Running 1 test case...
*** No errors detected
So far so good.
Now if I try to run inside Eclipse, I get an error. At first it appeared that my test was not running at all. In the "C/C++ Unit" tab, I got a red bar on the right side of the screen, no information where I should be seeing individual test results, and a message "XML parse error: Premature end of file" in small text right below the row of tabs. By stopping in the debugger, I was able to see that I'm victim of a known bug. Basically there's some incompatibility between Eclipse and boost testrunner, where one is specifying XML and the other xml (different case) for the format. I tried this work-around mentioned in the discussion about the bug at that link:
As a workaround you can add following arguments in the unittests' run configuration:
--output_format=XML --log_level=all --report_level=no --
Eclipse's test runner appends it's arguments to these. Arguments after -- are passed on to your test script and ignored by Boost.Test.
With that in place, I still have problems, but the problem is different depending on whether I run with debugging or not. Without debugging, the result is the same as noted above. With debugging, I get information about my test - noting that it ran and passed - on the left side of the "C/C++ Unit" tab but I still get the red bar indicating a failure. The small text in this case says: "XML parse error: Content is not allowed in tailing section."
The bug noted above appears to be about 2 yrs old, although the discussion has activity as recently as last month. I guess there's some other work around? It seems likely that the community has been running tests in the intervening two years!
I tried updating Eclipse via Help -> Check for Updates. That did not improve my situation. I suspect that other information may be valuable to help, but I'm not sure what to provide. I'll watch comments and update if / where I can.
Reluctantly, I upgraded to the Neon.2 release of Eclipse. The underlying bug is still present, as described in my question, but the work-around noted works in that release. Copying that down from the question for completeness:
As a workaround you can add following arguments in the unittests' run configuration:
--output_format=XML --log_level=all --report_level=no --
Eclipse's test runner appends it's arguments to these. Arguments after -- are passed on to your test script and ignored by Boost.Test.
Would have been nice if this worked in Mars as well since upgrading is a bit of a hassle - especially with support for multiple development languages - but at least I can move on. Probably would have had to upgrade at some point in any case.
I want to use C ++ to confirm local windows system python version installed, I do not know How to determine?
If the python directory has been added to the PATH environment variable, you can easily _popen python with the --version argument, and parse out the version number from the standard output (which will be e.g. Python 2.7.6).
Another option would be to use regedit to see if the version appears somewhere in the registry that you can read it from. Lots of existing S.O. Q&A on how to read registry values....
If you get stuck implementing either option, post your code and the specific problem.
I have been trying to run tests on RIDE (Robot Framework IDE). It used to warn about --monitorcolors option being depricated. In the latest install, it is unable to recognise. How do I change the options to make my tests run?
Thanks
The --monitorcolors option has been replaced with --consolecolors in Robot Framework version 2.9. The usage documentation for --consolecolors is here. You must be using the old option somewhere - check the Arguments string in the Run tab in RIDE.
I am setting up a new project to play around with the CLR and mono versus .NET. As a build environment/tool I chose NAnt, because I am familiar with Ant and it seemed best suiting.
While this is working very nice on different machines with different OSs, I am worried that some day, while I develop on a Windows machine, gmcs may not be able to build my sources, making them unavailable to other platforms using mono. So my idea to get around this is telling NAnt to always use gmcs inside the <csc> task. Is there a way to set the build script up that way? Or another workaround for my problem?
You can select the desired compiler using the default attribute of the plateform element in the configuration file Nant.exe.config.
You can also choose at runtime by using the -t switch. In example :
nant -t:net-4.0 will use csc and will target the .NET framework 4.0
nant -t:mono-2.0 will use mcs and will target the .NET framework
2.0
There is already a thread here that partially answers my question .
On Eclipse 3.7.2 I followed the approach provided there and I could successfully accomplish the steps creating and setting up a new error parser and adding it to my current project. After executing my Boost.Test (boost rel. 1.48.0) Unit Test, on the Eclipse console I get the same output as the output I get when no parsing is done (e.g. when executing the Unit Test outside Eclipse (e.g. on a Linux terminal)). I searched for a new Eclipse console where the parsed Unit Test output could be displayed (similar to the consoles by e.g. gcov, gprof or cppcheck in Eclipse) but found nothing alike.
Where should the parsed unit test output be displayed? In case the parsed output shall be displayed in the Eclipse Console view, are there any suggestions what might have gone wrong with the parsing in my case?
Thanks in advance.
P.S.: Thanks to casperOne and kleopatra for teaching me manners.
If you're using Eclipse there is also a really nice plugin called TestRunner for running CDT unit tests much like Java or Python unit tests. It handles the unit-testing parsing for you. You'll get a separate console window for your unit tests and it arranges them with level filters. Clicking on an error/warning takes you to the unit-test line number in your editor. You also can set the verbosity level as well as a few other settings from inside Eclipse.
You can directly install the plugin by using the following link in Eclipse updates https://raw.github.com/xgsa/cdt-tests-runner/tests_runner_demo/testsrunner/org.eclipse.cdt.testsrunner-updatesite/site.xml
In order to eclipse parse errors, the error must be print in the console view at compile time. If you are emitting errors in runtime, you must add your program to be called by the Makefile.
That's how I do in embedded systems.