Modify

Ticket #383 (closed defect: fixed)

Opened 2 years ago

Last modified 8 months ago

IfTask boolean issues with predefined properties

Reported by: saloon12yrd@… Owned by: mp
Priority: major Milestone: 2.5.0
Component: phing-core Version: 2.3.3
Keywords: properties, PhpUnitTask, boolean, ifTask Cc: Mp@…

Description

Hi all,

I discovered an anomaly in the IfTask in combination with the failureproperty of the PhpUnittestTask.

The environment is Phing 2.3.3 with PHPUnit 3.3.17 on Ubuntu 9.10 using bash.

If you initialize the property used as failureproperty in the PhpUnittestTask through a PropertyTask first, the IfTask does no longer work as expected. I attached three example build scripts to clarify this, but in a nutshell it is like this:

Assuming

<phpunit failureproperty="unittestFailed">

and

<if>

<equals arg1="${unittestFailed}" arg2="1" /> <then>

we have the following behaviour:

  • without initializing the unittestFailed property the if condition works as expected
  • with <property name="unittestFailed" value="false" /> the if condition will always enter the else-branch, regardless of the state of the unittests.
  • with <property name="unittestFailed" value="true" /> the if condition will always enter the then-branch, regardless of the state of the unittests.

This is not really a bug in my opinion, more a unclean behaviour. If might lead to incorrect behaviour however, if one and the same property (in this case unittestFailed) is used as common status flag for multiple tests which all have to go through.

Regards, Dominique

--  http://www.st/webdevelopment.de

Attachments

bug_works.xml Download (833 bytes) - added by anonymous 2 years ago.
bug_fails.xml Download (944 bytes) - added by anonymous 2 years ago.
bug_fails2.xml Download (943 bytes) - added by anonymous 2 years ago.

Change History

Changed 2 years ago by anonymous

Changed 2 years ago by anonymous

Changed 2 years ago by anonymous

comment:1 Changed 2 years ago by mrook

  • Keywords properties, added
  • Priority changed from minor to major
  • Milestone changed from 2.4.0RC3 to 3.0

You are completely right - the ambiguity lies in the distinction between user and system properties, something we need to look at properly. Therefore I'm moving this to the 3.0 branch for now. Thanks for the report!

comment:2 Changed 8 months ago by mp

Without having run the examples provided >:-) I'd guess the problem is that the task calls setNewProperty:

324                 $this->project->setNewProperty($this->failureproperty, true);

that should just be setProperty().

Of course it still fails if you set that property on the command line. Don't think that is an issue.

comment:3 Changed 8 months ago by mp

  • Cc Mp@… added

comment:4 Changed 8 months ago by mp

(In [1177]) Remove automagical conversion of strings to booleans. See  http://phing.tigris.org/ds/viewMessage.do?dsForumId=1079&dsMessageId=2771568.

Refs #633, #495, #376, #383.

Introduces a BC break for existing tasks.

comment:5 Changed 8 months ago by mrook

  • Milestone changed from TBD to 2.5.0

comment:6 Changed 8 months ago by mrook

  • Owner changed from mrook to mp

comment:7 Changed 8 months ago by mp

  • Status changed from new to closed
  • Resolution set to fixed

(In [1185]) Closes #383.

Note that you should use <istrue value="${property}" /> to check for failures.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.