Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make a blog post explaining how to run the unittests #146

Open
stdweird opened this issue Oct 1, 2015 · 13 comments
Open

make a blog post explaining how to run the unittests #146

stdweird opened this issue Oct 1, 2015 · 13 comments
Assignees

Comments

@stdweird
Copy link
Member

stdweird commented Oct 1, 2015

Placeholder for all stuff to put in the blog

@stdweird
Copy link
Member Author

stdweird commented Oct 1, 2015

convenience methods. set according to the environment if PERL5LIB cannot be set in bashrc

export QUATTOR_PERL5LIB=/usr/lib/perl:/home/stdweird/perl5/lib/perl5/

and use

function mvn_run {
    local unsetfn quatenv
    quatenv="PERL5LIB=${QUATTOR_PERL5LIB:-$PERL5LIB} QUATTOR_TEST_LOG_CMD_MISSING=1 QUATTOR_TEST_LOG_CMD=1 QUATTOR_TEST_LOG_DEBUGLEVEL=3"
    # make a subshell with all bashfunctions removed. maven can have issues with then via exporting with env.BASH_FUNC
    unsetfn=""
    for fn in `env |grep BASH_FUNC_ | grep -v grep | sed "s/(.*//; s/BASH_FUNC_//" |tr "\n" ' '`; do
        unsetfn="unset -f $fn; $unsetfn"
    done
    bash -c "$unsetfn $quatenv mvn $1"
}

function mvn_test {
    local extra
    if [ ! -z "$1" ]; then
       extra="-Dunittest=$1.t"
    fi
     mvn_run "clean test -Dprove.args=-v $extra"
}

function mvn_pack {
    mvn_run "clean package -Dprove.args=-v"
}

export -f mvn_run
export -f mvn_test
export -f mvn_pack

@piojo-zz
Copy link
Member

piojo-zz commented Oct 1, 2015

There is already documentation here . Feel free to update it.

@stdweird
Copy link
Member Author

stdweird commented Oct 1, 2015

gather debug logs

yum install -y perl-App-cpanminus.noarch  perl-devel gcc perl-Test-Simple
cpanm install Devel::Trace
perl -t -d:Trace `which ncm-ncd` --co fstab >& fstab_output

if no perl-App-cpanminus, do a yum install -y perl-CPAN, and install the module by

  • start cpan
  • type install Devel::Trace

@piojo-zz
Copy link
Member

piojo-zz commented Oct 1, 2015

Devel::Trace is available on Fedora, isn't it in EL6 or EL7?

@stdweird
Copy link
Member Author

stdweird commented Oct 1, 2015

to get value based regexptest for TT, pipe output of verbose mvn_test through

perl -e 'while (<>) { s/^# //; s/([(){}|[\]+\^\*\$\?#])/\\\1/g; s/^/^/; s/$/\$/; s/ {16}/\\s{16}/;s/ {12}/\\s{12}/; s/ {8}/\\s{8}/; s/ {4}/\\s{4}/; print; }'

@stdweird
Copy link
Member Author

if your, ~/.proverc contains --state=new,save, it will always run all tests

@jouvin
Copy link
Contributor

jouvin commented Dec 12, 2015

For the record, there is a page about unit test in the old wiki that I updated regularly: https://trac.lal.in2p3.fr/Quattor/wiki/Development/Code/TestingComponents. It may be good to start from it and when moved to quattor.org, remove it from the old wiki.

@jouvin
Copy link
Contributor

jouvin commented Dec 12, 2015

An issue I faced recently is the fact that set_file_contents doesn't make the file visible to get_file without using it with a CAF;;FileWriter. This is pretty unusual (in my case it was because the action done between set_file_content and get_file was silently failing) but this is confusing to see get_file failing... This needs to be documented.

@stdweird
Copy link
Member Author

stdweird commented Mar 9, 2016

If rpm packaging fails for no obvious reason (but has Unable to copy files for packaging:), run it with

PERL5LIB=/usr/lib/perl/ mvn package -e -X -Dprove.args=-v  

Then check the output for the created mappings: eg.g

[DEBUG]   (f) mappings = [["/usr/lib/perl/Test" {} from [{"/home/stdweird/.git/quattor/maven-tools/package-build-scripts/target/lib/perl/Test" failIfLocationNotExists:true filter: false}]], ["/usr/share/man" {% 
doc %attr(644,root,root)} from [{"/home/stdweird/.git/quattor/maven-tools/package-build-scripts/target/doc/man" failIfLocationNotExists:true incl:[ChangeLog] filter: false}]]]    

In this example the pom.xml had 2 mappings, and was based on the build-profile, and it seemed to overlay the mappings of te build-profile on the one in use. The ChangeLog include was thus added, and stuff failed.

The components have stuff like <mappings combine.children="append"> when adding new mappings.
Default is merge, you can also specifiy 'overrride' (but it seems it has no impact the way build-profile is made (it's nested, and then this looses all meaning)

@jouvin
Copy link
Contributor

jouvin commented Mar 28, 2017

I have the feeling that this issue has been fixed by @stdweird pages on Quattor development... Am I wrong? If yes, please consider adding/updating a documentation page rather than a blog post... See #212.

@ned21
Copy link
Contributor

ned21 commented Nov 3, 2017

I guess this is tracking the 7 TODOs listed in http://www.quattor.org/development/unittests.html ?

@jouvin
Copy link
Contributor

jouvin commented Apr 25, 2018

Plan is to fix it during April 2018 workshop

@stdweird
Copy link
Member Author

for the wrappers see quattor/maven-tools#175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants