is there a way to ignore a scenario within the command java -cp karate.ja:? - jar

I'm using a .jar, along with docker and a .sh to do the execution.
I use this command in .sh
java -cp karate.jar:./cases com.intuit.karate.Main "$#"
and I would like to use ~#ignore to not run some scenarios, is it possible?

Karate in version 1.1.0 onwards automatically ignores any scenario tagged as #ignore. Please refer the docs: https://github.com/karatelabs/karate#special-tags

Related

Karate Runner -> karate jar : Command line args settings issue

I am using Visual Studio code and Karate Runner plugin is installed. Using karate-config.js with standalone jar (karate.jar). I have tried to configure in karate runner settings in VS code for Karate Runner -> karate jar : Command line args as "java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main" but it throws an exception like
Executing task: java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9" <
Error: Could not find or load main class .config.dir=test.resources.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9"" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
Also, I have tried full path for -Dkarate.config.dir=D:/GitHub/KarateTestFramework/test/resources but didn't work either.
Please guide me to resolve this issue.
#ChandramohanRamabadran, I tried to replicate the issue on my system. I believe it's not a bug!
It's happening because your VisualStudio is using PowerShell instead of CMD. I believe you might have missed the step to change the default shell of VisualStudio after installing Karate. Try updating the default shell from PowerShell to CMD; then you should be good.
However, if you still want to use PowerShell, then update the command
java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main
to
java `-Dkarate.config.dir`=test/resources/ -cp karate.jar com.intuit.karate.Main
More context over the issue:
PowerShell has a more standard rule to parse system-properties parameters which are different from CMD. In a PowerShell command, the parameter names always begin with a hyphen. The hyphen tells PowerShell that the item in the command is a parameter name.
Here, we are passing the parameter as -Dkarate.config.dir, PowerShell sights the parameter name-tag as -Dkarate and not -Dkarate.config.dir; hence the error.
This is a bug. Thanks for reporting it: https://github.com/intuit/karate/issues/1330
For now please find a workaround. Karate will look for karate-config.js in the current directory or the classpath. So if you change the command to something like this (please try variations) it should work
-cp 'karate.jar;test/resources/'
I have changed preferred terminal shell from Powershell to command as default for VS code and followed the below listed steps
Press Ctrl + Shift + P to show all commands.
Type shell in the displayed text box to filter the list.
Select Terminal: Select Default Shell .
You will be prompted to Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now.
I have changed the karate runner->karate jar:Command Line Args settings as java -Dkarate.config.dir=resources/ -cp karate.jar com.intuit.karate.Main
Now its working fine.

how to use sbt shell to try small sbt expressions

like scala shell, does sbt shell provides a way to play around with sbt code
i.e. can I use sbt shell to create temporary tasks/settings and play with them
e.g. redefine existing definitions(in build.sbt) on sbt shell
I see set and eval commands but not sure how can I use sbt shell for testing some small sbt expression. I see that there session command as well.
Please provide a overview on how to try sbt shell as an interpreter of sbt expressions
You can try using consoleProject that allows you to eval settings and tasks and generally explore around your build. Its not the exact same thing that you're asking but maybe offers similar functionality?
Console Project Docs

Leiningen: Create executable jar to run without java -jar

I'm trying to understand how to package a command line application written in Clojure for distribution. I don't want users to have to use java -jar myproject.jar arg1 arg2 to run the program. PHP has something called "Phar" files, which are basically executable zip files, so they include a shebang that tells POSIX systems how to unpack and run them.
I've seen other Clojure apps that allow the jar file to be set chmod +x and then executed directly. How do they achieve this? Uberjar just seems to make a jar that requires the java -jar prefix.
You can do this using lein-bin.
Ah, I just found the answer to my own question. It's not standard functionality and you basically have to roll your own: https://github.com/tailrecursion/boot/blob/master/Makefile#L21

Look at Options in `.sbtopts` within Running `sbt`

Per this helpful post, I removed my ~/.sbtconfig, and added .sbtopts:
$cd myProject
$cat .sbtopts
-J-Xmx4G
-J-XX:+CMSClassUnloadingEnabled
-J-XX:MaxPermSize=4G
Then I ran sbt. How can I, via the sbt console, verify those options set in .sbtopts?
If you man sbt, you'll see that there's a debug flag; so, you'll see something like this:
$ sbt -d
[process_args] java_version = '1.7.0_72'
# Executing command line:
java
-Xms1024m
-Xmx1024m
-XX:ReservedCodeCacheSize=128m
-XX:MaxPermSize=256m
-XX:+CMSClassUnloadingEnabled
-XX:+UseConcMarkSweepGC
-jar
/usr/share/sbt-launcher-packaging/bin/sbt-launch.jar
Here's my sbtopts file: /usr/share/sbt-launcher-packaging/conf/sbtopts
-J-XX:+CMSClassUnloadingEnabled
-J-XX:+UseConcMarkSweepGC
Latest versions of the jdk comes with a nice tool called jps that tells you about running java processes
jps -v should point you to the processes and show the passed-in options
I don't know if you can do it from within the sbt console but you can add -J-XX:+PrintFlagsFinal to .sbtopts and the JVM will print all the flags.

run a "source" bash shell script in qmake

I want to use the intel compiler for Qt, but using the intel compiler implies running the script
$ source /opt/intel/bin/compilervars.sh intel64
Of course, I could add this to ~/.bashrc, but this would not run it in QtCreator, where it still complains about missing icpc. So I want it to be a part of the main mkspec qmake file.
How can I execute that full bash command in qmake?
Short Answer: Using QMAKE_EXTRA_TARGETS and PRE_TARGET_DEPS, you can execute source /opt/intel/bin/compilersvars.sh intel64, but simply sourcing them will not solve your issue.
Long Answer: The QMake file is converted into a Makefile. Make then executes the Makefile. The problem you will run into is that Make executes each command in its own shell. Thus, simply sourcing the script will only affect one command, the command that executes the script.
There are a couple of possible ways to make things work:
Execute the script before starting Qt-Creator. I've actually done this for some projects where I needed to have special environment variables setup. To make my life easier, I created a shell command to setup the environment and then launch Qt-Creator.
Within Qt-Creator, modify the Build Environment for the project I've also used this trick. In your case, simply look at the environment setup by the script and change the "Build Environment" settings under the project tab for your project to match those setup by the script.
It might also be possible to modify QMake's compiler commands, but I am not sure you can make it execute two commands instead of one (source the script then execute the compiler). Further more, this will make the project very un-transportable to other systems.
You can create a shell script that does more or less the following:
#! /usr/bin/env sh
# Remove the script's path from the PATH variable to avoid recursive calls
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PATH=${PATH/$SCRIPT_DIR:/}
# Set the environment up
source /opt/intel/bin/compilervars.sh intel64
# Call make with the given arguments
make "$#"
Save it into a file named "make" in an empty directory somewhere, make it executable, then change the build environment in QT Creator to prepend PATH with the script's directory:
PATH=[dir-of-make-script]:${Env:PATH}
You can do this either in the project settings or once and for all in the kit settings.
Like this, QT Creator will be fooled into calling your make script which sets up your environment before calling the actual make binary. I use a similar technique under Windows with Linux cross-toolchains and it has been working well so far.

Resources