How can I specify arguments to NUnit-console.exe in dotcover command line - code-coverage

I am working with nunit and dotCover for code coverage, if we run nunit-console.exe we need to provide arguments like :
& $nunit /nothread /noshadow /labels /domain=None /trace=Info /framework=net-4.0 /process=Separate
where $nunit is path to nunit-console.exe
but I am running nunit-console.exe with dotcover command line and I am providing following arguments
&$dotcover cover /TargetExecutable=$testRunner /TargetArguments=$test /Output="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\$testName.dcvr"
where testrunner is nunit-console.exe and $test has path to test.dll
but tests are not passing while running in Nunit.exe (UI app) they are passing.
is there any way I can pass required arguments to nunit in the dotcover script? so when dotcover covers nunit it will run with specified parameters.
I tried some workaround like this but it is not working &$dotcover cover /TargetExecutable=$testRunner /TargetArguments=$test /nothread /noshadow /labels /domain=None /trace=Info /framework=net-4.0 /process=Separate /Output="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\$testName.dcvr"
but it is showing this error:
[JetBrains dotCover] Not used command line parameter: 'nothread'
[JetBrains dotCover] Not used command line parameter: 'noshadow'
[JetBrains dotCover] Not used command line parameter: 'labels'
[JetBrains dotCover] Not used command line parameter: 'domain'

You should just need to quote the arguments for the NUnit Console.
&$dotcover cover /TargetExecutable=$testRunner /TargetArguments="$test /nothread /noshadow /labels /domain=None /trace=Info /framework=net-4.0 /process=Separate" /Output="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\$testName.dcvr"
Is there any chance that $test may contain quotes itself, or spaces? In which case, you need to quote it, and make sure that you escape the quotes inside quotes. Depends on exactly what command line you're using I think, but you'll probably want something a bit like this...
&$dotcover cover /TargetExecutable=$testRunner /TargetArguments="\"$test\" /nothread /noshadow /labels /domain=None /trace=Info /framework=net-4.0 /process=Separate" /Output="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\$testName.dcvr"

Related

Getting error for Data stage compare command line tool

I am using a utility provided in Data Stage 9.1 diffapicmdline.exe to compare two jobs from different environment. I am using following batch script code to read the job names from text file in loop:
#echo off
SET var=
for /f "delims=" %%i in (grm_deploy.txt) do (C:\IBM\InformationServer91\Clients\Classic\diffapicmdline.exe /lhscd "/d=cs1cd:9080 /h=cs1i04 /u=user/p=password cs1cdhbi04/IST_GRM %%i" /rhscd "/d=cs1cd:9080 /h=cs1i04 /u=test /p=Pass cs1cdhbi04/TEST_NIMISH %%i" /t job /ot html /ol E:\compare_output.html)
echo this is the end
However I am getting following error:
D:\dataStage Components\Scripts>read_file.bat
Validating syntax of /lhscd.
Unknown flag specified 'jbLoadStgARxAR'
this is the end
Can anyone let me know what is going wrong over here?

Converting Go testing output to XUnit

How can I have the output of Go's testing library output in XUnit format for integration with Jenkins? There are no command line options to output to XML or to XUnit format with go test.
There's a nice little plugin to convert: https://github.com/tebeka/go2xunit
To install it:
go get github.com/tebeka/go2xunit
To use it:
# Run your tests like normal, but pipe the verbose output to the converter
go test -v | $GOPATH/bin/go2xunit > test_output.xml
If you have $GOPATH/bin in your normal $PATH:
go test -v | go2xunit > test_output.xml

Execute Groovy script with arguments from Grails app

In reference to the question asked here
How to execute a Groovy Script from my Grails app?
which works except ...how do I pass arguments ?
def cmd = ['groovy.bat', 'C:\\my path\\mysript.groovy']
for a script that is run from the command line like
groovy myscript.groovy -name params.name -project params.name
using CliBuilder for arguments and params from form submitted
Groovy provides a simple way to execute command line processes. Yo can write the command line as a stringm and call the execute() method. Example:
"groovy myscript.groovy -name nancy -project testproj".execute()
More information in this link.
In case of arguments with whitespaces:
["groovy",
"my script with spaces.groovy",
"-name",
"nancy",
"-project",
"testproj"].execute()

how to invoke java.exe in bash under windows in cygwin with space in path

I tried to invoke java inside bash script on windows (Win XP) using cygwin.
However path to java.exe contain spaces.
only literaly putting in bash sometghing like this worked:
/cygdrive/c/Program\ Files/Java/jdk1.5.0_10/bin/java -cp "$TOOL_HOME" DateParse "$DATE" "$FORMAT"
My attemts to put java path to a variable failed:
export JAVA_EXE="/cygdrive/c/Program\ Files/Java/jdk1.5.0_10/bin/java"
$JAVA_EXE -cp "$TOOL_HOME" DateParse "$DATE" "$FORMAT"
also different combination with cygpath, quotes, brackets did not work. I am not finding the the right combination
Put quotes around $JAVA_EXE:
"$JAVA_EXE" -cp "$TOOL_HOME" DateParse "$DATE" "$FORMAT"
The problem is that every time a variable is expanded, its also broken into words at spaces, UNLESS you put quotes around it. So if you don't want things broken at spaces, you need quotes.
Another alternative is to always use short (DOS) names for things, which don't allow spaces. To see what the short name is, run
cygpath -d "$JAVA_EXE"
to convert that back to a unix-like cygwin path, use
cygpath -u $(cygpath -d "$JAVA_EXE")
thank you for your ideas. It worked in proper combination. The issue was that I was escaping space character and at the same time putting JAVA_EXE in quotes.
export JAVA_EXE="/cygdrive/c/Program Files/Java/jdk1.5.0_10/bin/java"
"$JAVA_EXE" -cp "$TOOL_HOME" DateParse "$DATE" "$FORMAT"
produce this effect:
line 30: /cygdrive/c/Program\ Files/Java/jdk1.5.0_10/bin/java: No such file or directory
on the other hand, converting to DOS 8.3 does not work neither:
cannot create short name of \\?\C:\Program\ Files\Java\jdk1.5.0_10
\bin\java
Finally, putting JAVA_EXE in quotes but without escaping space in path worked fine for me:
export JAVA_EXE="/cygdrive/c/Program Files/Java/jdk1.5.0_10/bin/java"
"$JAVA_EXE" -cp "$TOOL_HOME" DateParse "$DATE" "$FORMAT"

EXEC args (value) with quotes on linux from Ant script

bash shell:
./mimic_cmd "startDaemon()"
Corresponding Ant code:
<exec failonerror="true" executable="/bin/mimic_cmd">
<arg value='"startDaemon()"' />
</exec>
Does the Ant code exactly represent the above command at the bash shell? Based on the debug info, it looks like it:
[exec] Executing '/bin/mimic_cmd' with arguments:
[exec] '"startDaemon()"'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
Execute:Java13CommandLauncher: Executing '/bin/mimic_cmd' with arguments:
'"startDaemon()"'
The ' characters around the executable and arguments are not part of the command.
However, the Ant code returns and exit code of 1 while the Bash shell command returns 0.
Toggling vmlauncher doesn't help, and paths are all correct.
The same Ant code works on windows with the resulting debug output:
[exec] Executing 'C:\bin\mimic_cmd' with arguments:
[exec] '"startDaemon()"'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
Execute:Java13CommandLauncher: Executing 'C:\bin\mimic_cmd' with arguments:
'"startDaemon()"'
The ' characters around the executable and arguments are not part of the command.
Can you tell us what mimic_cmd is? (Is it an ELF executable, is it a script -- and if so, what is its contents?)
You don't need nor want the double-quotes inside your ANT XML attributes (incidentally, for it to be well-formed XML you should have written them as " not ", but that changes nothing with respect to this discussion) unless your executable expects them. The corresponding ANT code for either of the following (100% equivalent) shell command lines:
./mimic_cmd "startDaemon()"
./mimic_cmd 'startDaemon()'
./mimic_cmd startDaemon\(\)
./mimic_cmd startDaemon"()"
./mimic_cmd startDaemon'()'
...actually is:
<exec failonerror="true" executable="/bin/mimic_cmd">
<arg value="startDaemon()" />
</exec>
...or, for illustrative purposes:
<!-- spawn a shell with your original command line -->
<exec failonerror="true" executable="/bin/sh">
<arg value="-c" />
<arg value="/bin/mimic_cmd "startDaemon()"" />
</exec>
Why that is so is longwinded to explain; suffices to say that, in your specific case, the only time when you'd have to use double quotes would be when ultimately issuing the command via a *nix shell (either interactively or as part of another script or programatically via the execing of sh -c), and only in order for that shell not to think that the round parens () have special meaning. By the time the shell would in turn spawn mimic_cmd it would have already stripped the double quotes (and substituted backslash-escaped sequences etc. -- see how a *nix shell parses its command line) ANT does not run your command via the shell but rather executes it directly, so in this case mimic_cmd finds itself with a bunch of double quotes on its hand which it apparently doesn't know how to handle.
You essentially have to think of it as replacing all forms of shell quoting and escaping with XML escaping and breaing down into <arg/> tags.
Windows' CMD.EXE is special in the sense that, unline *nix shells, it does minimal parsing (and generally does not care about double quotes in program arguments), leaving it up to the program to figure out what you meant by quoting. (This is actually a hard limitation of Windows' CreateProcess which does not have the notion of argv[], leaving it up to each program to intepret lpCommandLine in whichever way it sees fit; some will get rid of the quotes for you, but that behaviour is extremely inconsistent, e.g. issue echo "bla" on the CMD.EXE prompt to see what CMD.EXE's builtins think about quoting.) Again, in your case the round parens () have no meaning for CMD.EXE so you don't need them even when typing the command at a command prompt. As for ANT, on Windows as on *nix platforms, it spwans mimic_cmd via CreateProcess not CMD.EXE so you don't really want to quote anything.

Resources