NANT: nunit3-console.exe requires the --inprocess swtich on one enviroment but not another - nunit

Using the following NANT script to execute an NUNIT test assembly (using nunit3-console.exe):
<target name="Test">
<exec basedir="${nunit.base.dir}"
workingdir="${unittest.test}"
program="nunit3-console.exe"
commandline="Test.dll"
failonerror="true" />
</target>
works fine on one machine, but on a different machine using the exact same basedir path, workingdir path, and Test.dll assembly, results in the following exception thrown by the nunit console runner (3.4.1):
[exec] System.Exception: Unable to acquire remote process agent
[exec] at NUnit.Engine.Runners.ProcessRunner.CreateAgentAndRunner()
[exec] at NUnit.Engine.Runners.ProcessRunner.LoadPackage()
[exec] at NUnit.Engine.Runners.AbstractTestRunner.Load()
[exec] at NUnit.Engine.Runners.AggregatingTestRunner.LoadPackage()
[exec] at NUnit.Engine.Runners.AbstractTestRunner.Load()
[exec] at NUnit.Engine.Runners.MasterTestRunner.LoadPackage()
[exec] at NUnit.Engine.TestEngine.GetRunner(TestPackage package)
[exec] at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package
If I use the --inprocess switch it will resolve the immediate issue. However, I need to use the --x86 swtich as well. --inprocess and --x86 are not compatible.
Any suggestions would be greatly appreciated.

Related

nunit with -test takes a loooong time to start - without works fine

I am using NUnit Console Runner 3.7.0 and similar nunit framework
Whenever I am running the console without specifying which tests to run, it runs at once.
As soon as I give it a few tests to runs it takes about 5 minutes to even start running.
I've tried running it against my testing dll and again against an .nunit project - same thing.
The assembly has about 130 tests but their discovery takes couple of seconds when using nunit -explore or visual studio test runner so it shouldn't be taking minutes to run them.
Example from my CI:
00:00:55.417 [exec] Test Filters
00:00:55.417 [exec] Test: T1
00:00:55.418 [exec] Test: T2
00:00:55.418 [exec] Test: T3
00:00:55.419 [exec] Test: T4
00:00:55.419 [exec] Test: T5
00:00:55.419 [exec] Test: T6
00:00:55.419 [exec]
00:06:29.678 [exec] => T1
00:06:29.685 [exec]
00:06:29.685 [exec] *******************************************************************************
00:06:29.685 [exec] *******************************************************************************
00:06:29.685 [exec] *******************************************************************************
00:06:29.685 [exec] S T A R T
00:06:29.685 [exec]
Edit:
NUnit call(using nant):
<exec
program="nunit3-console.exe"
basedir="${nUnit.path}"
workingdir="${source.path}"
timeout="14400000"
verbose="true">
<arg value="${source.path}\Sources\Test.nunit" />
<arg line ="--x86" />
<arg line ="--labels=All" />
<arg line ="--result=TestResult.xml" />
<arg line ="-test=T1,T2,T3,T4,T5,T6" />
</exec>
When doing it manually:
nunit3-console.exe Test.dll --x86 -test=T1,T2,T3,T4,T5,T6
Seems to me that this might be a bug in nunit 3*.
I've reverted to nunit 2.6.4 and it has no such problem.

Worklight ant tasks for deployment

I am using this documentation.
It tells me to do a ant target like this.
<target name="Deploy App">
<app-deployer deployable="${build.apps.dir}/app.wlapp"
worklightServerHost="http://${customConfig.worklightServer.host}:${customConfig.worklightServer.port}/${customConfig.runtime}"
userName="admin" password="admin" />
</target>
However when I run this target it tells me that app-deployer task is deprecated and I should use something else.
The entire message is below:
[app-deployer] The Ant task <app-deployer> is no longer supported.
[app-deployer] You need to replace this invocation with an invocation of the <wladm> Ant task, like this:
[app-deployer] <taskdef resource="com/worklight/ant/deployers/antlib.xml">
[app-deployer] <classpath>
[app-deployer] <pathelement location="buildTools\buildJars\worklight-ant-deployer.jar"/>
[app-deployer] </classpath>
[app-deployer] </taskdef>
[app-deployer] <wladm url="** URL of Worklight administration services **" user="admin" password="admin">
[app-deployer] <deploy-app runtime="** project runtime name **" file="app.wlapp"/>
[app-deployer] </wladm>
[app-deployer] where values between ** markers are to be filled in.
The version of the worklight ant deployer I'm using is this.
[echo] Worklight Ant task version 6.2.0.00.20140613-0730
Nevertheless, when I create a target with wladm it tells me that
Problem: failed to create task or type wladm
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
The most frequent causes for said error message "failed to create task or type wladm" are:
The <taskdef> has not been executed at this point, in the current Ant script. You may have it in a different target, that is not executed before the current target. The fix is to list it in a common initialization target, or outside of any targets, directory under <project>.
The <taskdef> refers to a nonexistent file or to an older version of worklight-ant-deployer.jar than 6.2.0.
The <taskdef> loads resource="com/worklight/ant/defaults.properties", but in 6.2 it needs to load resource="com/worklight/ant/deployers/antlib.xml".
Not exactly an answer to your question but if you do not need Ant, you can use wladm in command line. See doc at https://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.appadmin.doc/admin/r_wladm_program_app_commands.html
The wladm command is in [WorklightInstallDir]/shortcuts

Building Windows 8 Phone App on Command Line

I'm currently porting an existing cross platform framework to Windows Phone 8.
The build process is fully automated and we are using a rock solid CI system.
I can build and deploy Windows Phone 8 samples from Visual Studio (Express 2012),
but now I need to integrate that into our build scripts.
Did anybody ever successfully build (and deploy) a Win Phone 8 app via the commandline?
(Or ant, make, scons, whatever...)
If yes, how?
Any hints are welcome.
I used the following bat file to build WP7 code (+ant automation on top of it). It may be helpful for you.
build.bat
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe build.xml /t:BuildAndCopy /p:Revision=123
where build.xml is something like (build itself goes under BuildAll target)
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<PropertyGroup>
<Major>1</Major>
<Minor>0</Minor>
<Build>0</Build>
<Revision>x</Revision>
<OutputPath>Build\</OutputPath>
<OutputPathDebug>..\Build\Debug\</OutputPathDebug>
<OutputPathRelease>..\Build\</OutputPathRelease>
</PropertyGroup>
<Target Name="BuildAll" DependsOnTargets="Clean; Version">
<msbuild Projects="SomeApp.sln" Properties="Configuration=Release;OutputPath=$(OutputPathRelease)"/>
<msbuild Projects="SomeApp.sln" Properties="Configuration=Debug;OutputPath=$(OutputPathDebug)"/>
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(OutputPath)" Condition="Exists('$(OutputPath)')"/>
<MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')"/>
</Target>
<Target Name="Version">
<Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>
<XmlUpdate
Namespace=""
XmlFileName="WindowsPhone\Properties\WMAppManifest.xml"
XPath="//App[#Version]//#Version"
Value="$(Major).$(Minor).$(Build).$(Revision)"/>
</Target>
<ItemGroup>
<AppFiles Include="$(OutputPath)\**\*.xap"/>
</ItemGroup>
<Target Name="BuildAndCopy" DependsOnTargets="BuildAll">
<Copy
SourceFiles="#(AppFiles)"
DestinationFiles="#(AppFiles->'\\fs\Public\projects\mobile\SomeAppWP\$(Major).$(Minor).$(Build).$(Revision)\%(RecursiveDir)%(Filename)%(Extension)')"
/>
<Copy
SourceFiles="#(AppFiles)"
DestinationFiles="#(AppFiles->'\\fs\Public\projects\mobile\SomeAppWP\latest\%(RecursiveDir)%(Filename)%(Extension)')"
/>
</Target>
</Project>
It should be easy. I'll assume you have the following file structure
$/WP8App/SampleApp.sln
You will have to use the paths and solution file in your project. Execute the following instructions, and make sure to update solution file and path:
Open a command prompt
Execute: %VS110COMNTOOLS%vsvars32.bat
Execute: %VS110COMNTOOLS%..\..\VC\WPSDK\WP80\vcvarsphoneall.bat
Execute: MSBuild "WP8App/SampleApp.sln" /t:rebuild
/p:Configuration=Release /p:Platform="Any CPU" /v:d
Please notice:
The computer where you're going to run these commands should have the development environment for WP8 already set up.
If your application uses native libraries (such as PlayerFramework http://playerframework.codeplex.com/ which are installed into VS, these libraries should also be installed before running the commands)
I have used this process on VS2012 Pro and VS2012 Premium and Jenkins as Build Server.
Good luck,
Herb
Thanks to Sergei's MSBuild.exe hint I was able to build a simple sample via the command line.
https://github.com/AndreasOM/wp8-directx-commandline
There is a build.bat included, which should be enough to get you started to build for "windows phone 8" with the build system of your choice.
It's fairly hacky at the moment,
but once I get the current project done
I will clean it up.
Hint:
Never define a "CL" environment variable when working with "CL.exe" ;)

Setting PATH environment variable on ant build.xml works on cygwin but not on cmd or PowerShell

I was trying to set PATH enviroment variable on an ant build.xml through this answer.
It works on cygwin but not on cmd or PowerShell.
Some information:
Apache Ant 1.6.5 (I know there is a newer version (1.8.4), but for internal reasons I have to use this older version)
Powershell v2.0
cmd v6.1.7601
cygwin 2.774
Windows 7
You may need to use the exec task a little differently on Windows/cmd environments.
Let's use the windows command set as an example. set will print environment variables. A normal exec task running a set command might look like:
<exec executable="set" outputproperty="set.output">
<env key="MY_VAR" value="MY_VAL"/>
<echo message="${set.output}"/>
</exec>
But using this form of the exec task should throw an IOException: The system cannont find the file specified.
When running ant under windows cmd shell, the exec task can also be invoked via cmd, like this:
<exec executable="cmd" outputproperty="set.output">
<arg line="/c set"/>
<env key="MY_VAR" value="MY_VAL"/>
<echo message="${set.output}"/>
</exec>
This is the equivalent command; the actual command executed is cmd /c set, which is running set in a cmd sub-process.
The reason why this is necessary is only a little complicated and is due to the way that the commands are located by Win32 ::CreateProcess. The ant exec docs briefly explain this.
Note that I haven't tried either of these using PowerShell, so I have no experience which, if either, will work.
In my own ant build scripts I typically have two versions of each target that require special handling for windows platforms, with an isWindows test that looks like this:
<target name="check-windows">
<condition property="isWindows">
<os family="windows"/>
</condition>
</target>
Then I can switch between versions of the same task using:
<target name="my-target-notwindows" depends="check-windows" unless="isWindows>
...
</target>
<target name="my-target-windows" depends="check-windows" if="isWindows>
...
</target>
<target name="my-target" depends="my-target-notwindows,my-target-windows">
...
</target>
Unfortunatelly was an ant bug related to 1.6.5 version. I was able to update to 1.8.4 and everything works fine.

Nant Build Error-- Nested build failed

I have a HelloNAnt.build file inside the directory:
D:\third party components\nant\WhatThis
My nant exe is placed at
C:\Program Files\nant
So I cd to D:\third party components\nant\WhatThis, type in the following command line:
"C:\Program Files\nant\bin\nant.exe" HelloNAnt.build
I got a build failed error, saying target HelloNAnt.build does not exist in this project.
What actually went wrong?
The content of HelloNAnt.build:
<?xml version="1.0"?>
<project name="Hello World" default="hello">
<target name="hello">
<echo>Hello</echo>
</target>
</project>
You omitted the -buildfile option, which specifies the path to the buildfile that you want NAnt to run:
"C:\Program Files\nant\bin\nant.exe" -buildfile:HelloNAnt.build
However, in your case, you needn't provide any options at all. NAnt will search the current directory for a file with a .build extension and run it.