How to force Phing task to respect verbose exec command? - phing

In other words how to display output of currently executed phing task?
<target name="backup_db">
<mkdir dir="${dir.sql}"/>
<exec command="mysqldump -v -h ${db.host} -u ${db.username} -p${db.password} ${db.name} > ${dir.sql}/${dump.basename}"/>
</target>
This pulls a database dump, as you see I specified -v flag to get verbose output. Command runs successfully however with no output during the dump.
Foo > backup_db:
BUILD FINISHED
Total time: 1 minute 40.81 seconds
The same command called directly in terminal will list each table one by one that's currently being dumped. How to achieve that in phing?

Adding passthru="true" to the exec solved the problem. Now I get the output in real time.

Related

Is there a way to run pytests using xdist by file(s)?

I am trying to run 2 test files using xdist with 2 gateways (-n=2). Each test file contains tests which are user permission specific. While running the test with pytest and pytest-xdist, I noticed some of the test fail randomly. It is happening because some of the tests from file1 getting executed by a different gw. So, if [gw0] was running most of the tests from file0, sometimes, [gw0] also executes some tests from file1 which causes the failure.
I am trying to find out if there is a way I can force/ask xdist to execute a specific file or perhaps if there is a way to assign a file to a gw?
pytest test_*.py -n=2 -s -v
also tried:
pytest test_*.py -n=2 -s -v --dist=loadfile
Assuming your file for running parallel tests is correctly distributed (properly receiving PYTEST_XDIST_WORKER and PYTEST_XDIST_WORKER_COUNT environment variables), you only need to run:
pytest test_*.py --tx '2*popen' --dist=loadfile --dist=each

Parallel execution of robot tests in Sauce Labs

I am using Eclipse+Maven based Robot Framework with Java implementation of SeleniumLibrary.
I could execute tests in sauce labs but it executes only on one VM. Has anyone achieved parallel execution of robot tests in Sauce Labs say in multiple VMs? Or can anyone guide to achieve this? Thanks in advance.
This is what I am using to run on multiple concurrent VM's on saucelabs. I have a 1-click batch file that uses start pybot to invoke parallel execution. Example:
ECHO starting parallel run on saucelabs.com
cd c:\base\dir\script
ECHO Win7/Chrome40:
start pybot -v REMOTE_URL:http://user:key#ondemand.saucelabs.com:80/wd/hub -T -d results/Win7Chrome40 -v DESIRED_CAPABILITIES:"name:Win7 + Chrome40, platform:Windows 7, browserName:chrome, version:40" tests/test.robot
ECHO Win8/IE11
start pybot -v REMOTE_URL:http://user:key#ondemand.saucelabs.com:80/wd/hub -T -d results/Win8IE11 -v DESIRED_CAPABILITIES:"name:Win8 + IE11, platform:Windows 8.1, browserName:internet explorer, version:11" tests/test.robot
-T tells pybot to not overwrite result logs but create a timestamped log for each run
-d specifies where the results will go
Works like a charm!
A parallel executor for Robot Framework tests. With Pabot you can split one execution into multiple and save test execution time.
https://github.com/mkorpela/pabot

Can't run psql from an ant target running in NetBeans 8.0.2

I'm running PostgreSQL 9.2 on Windows 7. I'm trying to run an Ant target using an apply tag with the executable property set to psql from a NetBeans 8.0.2 build file. I have created a pgpass.conf file in the right place with the correct password for the postgres user and I can run psql at a command prompt without having to enter a password. But when I run the Ant target, I get an error message in the output file saying the target failed because no password was supplied. What am I doing wrong? The target looks like this:
<filelist id="create-dbfiles" dir="${root}" files="createdb.sql"/>
<target name="create-db">
<apply executable="psql" addsourcefile="false" output="output.txt">
<arg value="-U postgres" />
<arg value="-w" />
<filelist refid="create-dbfiles"/>
<redirector>
<inputmapper type="glob" from="*" to="${root}\*" />
</redirector>
</apply>
</target>
a_horse_with_no_name got me thinking about the exec tag but trying to run psql directly via an exec tag or an apply tag still threw up errors about a password not being supplied. Then I realised that psql ran smoothly from the cmd prompt. I started playing around with calling cmd.exe and passing a command to the command line, and found a solution:
<filelist id="clean-dbfiles" dir="${root}" files="cleandb.sql"/>
<target name="clean-db">
<apply executable="cmd.exe" addsourcefile="true" >
<filelist refid="clean-dbfiles"/>
<env key="PGPASSWORD" value="rootpassword"></env>
<arg value="/c"></arg>
<arg value="psql -w -U postgres -f " />
<srcfile />
</apply>
</target>
<filelist id="create-dbfiles" dir="${root}" files="createdb.sql"/>
<target name="create-db">
<apply executable="cmd.exe" addsourcefile="true" >
<filelist refid="create-dbfiles"/>
<env key="PGPASSWORD" value="rootpassword"></env>
<arg value="/c"></arg>
<arg value="psql -w -U postgres -f "/>
<srcfile />
</apply>
</target>
Here are the two key targets for creating a build script for a postgres database. Note the following points:
Run cmd.exe not psql directly
Set addsourcefile to true because I want to call neat little self-contained SQL files for each target.
Use apply with a filelist because for my createtables or populate targets I may have a directory of separate SQL files
Give up on hoping to invoke the pgpass.conf file. For some reason Ant in NetBeans can't access it. Resort to the PGPASSWORD environment key and set it to the desired password. This is running locally for development purposes so security isn't an issue.
You need to pass the /c switch to cmd.exe so that you can then pass a command line. I didn't separate the psql command line into separate arguments because I think the complete line is being passed to cmd.exe as a single argument.
addsourcefile is set to true so each file in the filelist is appended to the psql command line just after the -f switch and everything works a treat.
VoilĂ ! What a fuss! I had no similar difficulty with MySql because you can pass the password to the command line directly.

EXEC timeout not work with matlab application

I have used EXEC task to open matlab in build.xml file. I have added timeout in EXEC task for terminate the task after some time. But problem is that, matlab is open and model is also building in matlab but after timeout the exec task not terminate.
<property name="BuildEngine.calc.matlabApp" value="C:\MATLAB\R2010bSP2\bin\matlab.exe"/>
<property name="modelProjectDirectory" value="${basedir}\..\${Config.ModelProject}"/>
<exec executable="${BuildEngine.calc.matlabApp}" dir="${modelProjectDirectory}" timeout="60000">
<arg value="-r"/>
<arg value="OutputResolvedParameters"/>
</exec>
after 1 min EXEC task not terminate and matlab still running.
One thing is sure: you cannot yet set up a timout on an RTC build: the Enhancement 106064 (you need a jazz account to see it) is "triaged".
Regarding the ant exec task, try adding a spawn=true attribute:
If you run Ant as a background process (like ant &) and use the <exec> task with spawn set to false, you must provide explicit input to the forked process or Ant will be suspended because it tries to read from the standard input.

Run ant exec task from different folder

I want to run my "exec grails" task into my grails project. I set grail path in exec task like
<exec executable="${grails}"
How can I say , that exec should start from my project folder?
From the exec Ant task documentation:
Attribute Description
dir the directory in which the command should be executed.
<exec executable="${grails}" dir="${my.project.dir}">