In Leiningen invoke another task from test task - leiningen

For running tests I use the default test task in Leiningen like
lein test
As part of this task I wanted to run another plugin task. Specifically the lein-cljfmt plugins check command which can be invoked in a standalone manner like
lein cljfmt check
Is it possible to run the cljfmt check command as part of the lein test task invocation?

Yes. You can define an alias under the aliases key. Thus if your test alias is the only alias in your project.clj file, aliases would look like this:
:aliases {"test" ["do" "test" ["cljfmt" "check"]]}
With this alias set up lein test would now actually be doing lein do test, cljfmt check.
See https://github.com/technomancy/leiningen/blob/master/sample.project.clj for examples.

Related

Testcafe: find current working directory from test

I have a working TestCafe test suite which generates a custom xml report generated by code in the test suite. I would like to place this report in the "standard" ./results location that TestCafe uses for its reports, but I can't find an option to retrieve the current working directory (e.g., the bash pwd command).
I'm getting it by adding export pwd=$(pwd) on the command line when I run the test, but I wonder if there's a built-in mechanism in TestCafe to do this?
If you run the tests from the command line, you can just use the reporter option as follows:
testcafe chrome test.js --reporter xunit:results/output.txt
See this question for details: How to save report results from console to a file (TestCafe)?.

How to execute commands during S2I build in Openshift?

Openshift CLI command to start S2I (source to image) build looks like this:
oc start-build buildname --from-dir=./someDirectory--wait=true
But how can we execute some shell command? os start-build is going to create image (described in the build definition) and copy someDirectory to it, but what if we need additional configuration of that image, not only to push compiled source code there?
There're a couple of options:
Provide a layer in the Dockerfile
Override assemble script
assemble script override options:
Provide .s2i/bin/assemble into the code repository
Specify spec.strategy.sourceStrategy.scripts in the BuildConfig with URL of a directory containing the scripts (see override builder image scripts)
Example of assemble script and s2i workflow you can check in s2i or there's simple example:
#!/bin/bash
# Run additional build before steps
# Execute original assemble script.
/usr/libexec/s2i/assemble
# Run additional build after steps
In addition, There's postCommit build hooks which executes after commiting the image and before pushing it to the registry. It executes in temporary container so it can only be used to do some tests.

Custom Reporting to Jenkins

I'm trying to hook up our own private testing tool to Jenkins. I'm able to run the test through the command line and create a report on my local machine. I will need to convert that report to xml JUnit format, specifically for Jenkins. Once that is done, how do I associate the xml file that was just created to the most recent job. This way the correct report gets put with the correct job?
The way Jenkins works is simple: you create a job and Jenkins runs it. Every run of a job is called a build. If you configure the job to look for test report files at the end of a build, the test reports are loaded and presented in the Jenkins UI. There is no way to submit test reports to a build outside of the build or after the build.
Usually this is not a problem. You run your test program/script as part of the build and it produces xml files in the JUnit format. When all the build steps are done, Jenkins looks for the xml files and loads them. You have to tell Jenkins to do it, though. You open the job configuration and you add a new post-build action titled "Publish JUnit test result report". Then you give Jenkins a pattern it uses to search for the files. You can use **/*.xml which means Jenkins will look for all *.xml files in every directory and subdirectory. Or you can e.g. use **/testreports/*.xml if you know where the test reports are going to be.

How to call ant from perl script that is called from Hudson

Hudson allows us to specify the ant version that we want to use. Now, what I want to do is having Hudson call my perl script which then will call ant. how do I do this?
When I tried to call ant from perl script that was called from Hudson, I got the following error:
Can't exec "ant": No such file or directory at ...........
I understand that this error means "ant" is not in the path. The thing is that if I provide the exact location or add ant to the path, then that means I am not using ant that I specified from Hudson.
Can anyone help?
It looks like you don't actually want to invoke ant as a Hudson build step which will happen if you add it as a build step. How about making it a parameterized Choice as ANT_VERSION with options: /opt/apache-ant-1.8.0, /opt/apache-ant-x.y.z, etc. Then in your Execute Shell build step do:
my-perl-script.pl --ant-version=${ANT_VERSION}
where your script takes the path to the ant version as a paramter.

How to configure jenkins to generate Test Results with code coverage using NCover

I have installed NCover in my CI server . How can I configure jenkins to show html reports with contains test results with code coverage?
I have found a post but it is using something called Gallio ( http://blog.teamlazerbeez.com/2009/08/04/using-ncover-for-net-code-coverage-with-hudson/ ).
Finnaly I ended up with this http://codetuner.blogspot.com/2011/06/ncover-command-line-for-mstest.html