Load test directory into the rebar3 shell - erlang

When I boot up a rebar3 shell I can't access any of the modules in my test/ directory. I would like to try out some of the helper functions I've written there, how can I do it?

With rebar3 tests are run under the test profile, so run your shell with that profile:
rebar3 as test shell

Related

How do I tell rebar3 to use werl on Windows?

This may apply to any rebar commands but it is mostly about rebar shell.
By default rebar uses erl and this might be clunky on Windows shells.
According to this source
You can run rebar3 (and any other escript) with werl by specifying the
ESCRIPT_EMULATOR environment variable. In a Git bash that would be:
ESCRIPT_EMULATOR=werl rebar3 shell

Using Rebar3 Common Test does not find hrl files in the include folder but eunit does

Using rebar3 eunit it is able to handle -include("some_file.hrl") in the tests, but this doesn't work with rebar3 ct. For some reason when I use rebar3 ct it tries to compile my eunit tests and fails because it can't find the .hrl files used in the eunit tests. ...can't find include file "some_file.hrl" What am I doing wrong? Why is it compiling eunit tests when I'm trying to run CT tests?
Quick answer:
Additional compile options for eunit. erl_opts can be used like this with rebar3:
{eunit_compile_opts, [
{i, "custominclude"},
{i, "include"},
{i, "deps/nice/include"},
{i, "/usr/lib64/erlang/lib/some-1.3.0/include"}
]}.
https://github.com/erlang/rebar3/blob/fb363cd8de68e9113e407ac0be049cacdd9ddd07/rebar.config.sample#L165
More about this subject
rebar3 change the way eunit tests are performed.
Original rebar2 behavior was to compile your project and anything in the test directory (including subdirectories) to the directory .eunit and then run tests from every file. That's why your include files directive may work under rebar2 simply because all files are included and centralized.
Rebar3 instead, by default, sets Tests to [{application, yourapp}].The eunit command of rebar3 first does some preparation work and after this calls eunit:test(Tests, EUnitOpts).
Notice that:
test sets can be specified via {eunit_tests, [...]} in rebar.config
rebar3 has application, module, file and dir command line flags that mirror the eunit test representations.
http://www.rebar3.org/docs/from-rebar-2x-to-rebar3
Since rebar3 ct will take all this in account, being more configurable and less automated (not including all of your applications and deps) this may happen to you.

Jenkins + CasperJS

I have a series of frontend tests written in CasperJS that I need to run in Jenkins. Here is command I run from the command line: casperjs test ./src/tests/**/ts_*.js --xunit=xunit.xml. This runs the tests and saves the xunit file. Ok. When I have Jenkins run the same command it gets through loading the first test page and spits out this error: "Process leaked file descriptors" and directs me to: https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build
It provides an explanation and a few OS specific work arounds. The environment this will be run on will eventually be linux however my development environment is Windows and I don't understand the workaround they provide. What kind of file is that and how does it fit with Jenkins?
Does anyone have experience running CasperJS tests using Jenkins?
I installed jenkins as a service and use default settings.
I solved same issue on windows.
if you are running as a service and default home directory ( c:/program files(x86)/jenkins/ )
you have to change path to other normal folder(ex.c:/jenkins/").
SET JENKINS_HOME=c:\jenkins\
What I do with jenkins and casper:
I create a job with string parameter 'tests', which takes *.js or specified test
and try to run casper tests via Build -> Execute shell
cd ~/test_directory
casperjs test ${tests}

Executing custom shell script to build in jenkins

I have setup a jenkins job to build my project. I have a jake.sh file in my project and the code is pulled from github. I want "npm install" command to be executed and then jake.sh to be executed once the the code is checked out.
How can I configure this in jenkins? I have tried givin ./jake.sh and jake.sh in Build->Execute Shell section
According what you tell I think the problem can be
The script is not marked as a executable. In this case add in Build -> Execute Shell (in case you have linux) sudo chmod 777 path_to_script/jake.sh.
The script is not in the base directory. Remembeber that when you execute a bash script, the current directory is /path_to_job/workspace. So you have first to move to the script folder (cd path_to_script) or specify the path when running it: ./path_to_script/jake.sh.
I hope this solves your problem.
A workaround for shell scripts can be to run the script as
bash ./jake.sh
instead of
./jake.sh
Then you don't have to do chmod. Useful when you wipe the workspace before every build.
In the same manner, if you have a nodejs shell script or python script, you can run node myscript.js / python myscript.py.

Easy way of loading project's Rebar dependencies in Erlang shell

I've got a project that uses Rebar as build tool. When developing, I would like all my app dependencies that are specified in Rebar.config be compiled & loaded in the shell as easy as possible. I'm using the Erlang shell in Emacs. What's a quick way to do this?
I'm not using Emacs so I may miss the Emacs-specific side of your question, but when I want an Erlang shell with all my rebar dependencies loaded, I use:
erl -pa ebin deps/*/ebin
./rebar shell
should load all your dependencies.

Resources