Sorry, Sending it again from gmail account as last send wasn't accepted by php.list ... spam filtering ... etc .
Tony, Thank you for all your comments, I am sure they will be helpful in making testcases more better. Please see my reply below. With Regards, Raghubansh Antony Dovgal <[EMAIL PROTECTED]> 24/07/2007 04:13 To Raghubansh Kumar <[EMAIL PROTECTED]> cc php-cvs@lists.php.net Subject Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard/tests/file
Raghubansh, could you please make those tests smaller? 5-10 lines are enough.
Sure. I'll split and commit them soon.
Just an example: ext/standard/tests/file/lstat_stat_variation2.phpt fails here. Here is the .diff I get:
016+ stat1 is not lesser than stat2 at key value: 8 017+ stat1 is not lesser than stat2 at key value: atime 018+ bool(false) 016- bool(true)
Can you tell me what's wrong there offhand? Which function is failing? And with which input data?
The failure is coming from comparison of two stat values taken before touching a link file and after. The stat() value of the file is taken and then touch() is performed with a gap( of few seconds) on the link file and new stat is recorded. Later both the stat is compared for access time difference as touch changes the access time of file. The access time is stored in the index 8 and key index 'atime' of the returned array from stat. Function compare_stats() is comparing fields: 1. value of key 8 of old and new stat 2. value of key index 'atime' of old and new stat [as the same value is stored in stat array twice (with numeric key index and with string key index]. The failure is because the access time is not changed, which should have been. Here is the code: ... // touch a link echo "-- Testing lstat() for link after using touch() on the link --\n"; $old_stat = lstat($link_name); // clear the cache clearstatcache(); sleep(2); var_dump( touch($link_name) ); $new_stat = lstat($link_name); // compare self stats var_dump( compare_self_stat($old_stat) ); var_dump( compare_self_stat($new_stat) ); // compare the stat $affected_members = array(8, 'atime'); //below line produces the message as expected comparison fails var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") ); ...
It seems to be easy to find the reason of the failure.. BUT when I take look into the test, I don't feel like doing it anymore.
First of all, for some reasons there are 3 tests in one file: 1) Testing stat() for file after using touch() on the file 2) Testing stat() for directory after using touch() on the directory 3) Testing lstat() for link after using touch() on the link
Why do you put them all in one file? They certainly deserve to be in separate files.
All the three tests are trying to test the effect of touch() and see the changes that are recorded by stat and lstat functions, hence all of them were grouped together.
Second, compare_self_stat(), compare_stats() - what do these funcs do? I
don't know.
Good thing is that we don't have any cycles here, as it's impossible to
debug something failing on 81th iteration. We have put in function descriptions for compare_self_stat and compare_stats() functions. They are described in file.inc. These functions are for comparing stat array(s). 1) stat array contains the same value twice in the array once with numeric key index and secondly with a string key index of the values. The compare_self_stat() compares this two values (in the same stat array) with each other to see they are same. This comparison is done with ever stat recorded to check that they are as expected. 2) compare_stats(): compares two different stat array to see what are the differences. The function is capable of doing the comparison (different conditional) based on the callers choice. e.g. one can pass two stat array and say that compare only field no 8 and filed with named key 'atime' for equality, lesser than, etc. Since these comparison are done N number of times, these common functions are written and placed in a common file so that repetitive code can be avoided. However, i think, i can add more description in the function description and in tests to improve it. :) ------------
So that's what we have at the moment: to understand why this test fails I need to go over all funcs in
file.incand understand what do they do.
Then I should return to the test, find which of the three "embedded tests"
is failing, move it into a separate file >to get short reproduce code and then debug this short script. File system testcases demanded many common operations to be performed in most of the testcases, frequently, hence writing a common file (an include file) seemed avoidable. I understand the pain in generating the small reproducible code, making tests even more smaller and more comments/description would improve this, I am sure. ------------
This is how it should theoretically look like: I need to look into the test, which ALREADY contains the short reproduce
code and understand the issue from the first glance.
One test, one point of failure, one reason, one possible bug. That's of course an ideal case, but we should strain after it.
Please, we don't need tests just for tests. I don't want to spend hours on debugging a test (like I did with the huge
link() test), it should HELP me to debug PHP instead.
Also, pretty please do not put tests for several functions in one test
file.
Things like "testing func1(), func2(), func3(), func4() and func5()" are
not acceptable,
these tests do not perform their primary function - they do not help the
developers,
the result is quite the contrary.
I'll try n get more smaller testcases and avoid having multiple function in a single testcases where ever possible so that it is much easy for developer and help them ease their work. with Regards, Raghubansh On 7/24/07, Antony Dovgal <[EMAIL PROTECTED]> wrote:
Raghubansh, could you please make those tests smaller? 5-10 lines are enough. Just an example: ext/standard/tests/file/lstat_stat_variation2.phpt fails here. Here is the .diff I get: 016+ stat1 is not lesser than stat2 at key value: 8 017+ stat1 is not lesser than stat2 at key value: atime 018+ bool(false) 016- bool(true) Can you tell me what's wrong there offhand? Which function is failing? And with which input data? It seems to be easy to find the reason of the failure.. BUT when I take look into the test, I don't feel like doing it anymore. First of all, for some reasons there are 3 tests in one file: 1) Testing stat() for file after using touch() on the file 2) Testing stat() for directory after using touch() on the directory 3) Testing lstat() for link after using touch() on the link Why do you put them all in one file? They certainly deserve to be in separate files. Second, compare_self_stat(), compare_stats() - what do these funcs do? I don't know. Good thing is that we don't have any cycles here, as it's impossible to debug something failing on 81th iteration. ------------ So that's what we have at the moment: to understand why this test fails I need to go over all funcs in file.incand understand what do they do. Then I should return to the test, find which of the three "embedded tests" is failing, move it into a separate file to get short reproduce code and then debug this short script. ------------ This is how it should theoretically look like: I need to look into the test, which ALREADY contains the short reproduce code and understand the issue from the first glance. One test, one point of failure, one reason, one possible bug. That's of course an ideal case, but we should strain after it. Please, we don't need tests just for tests. I don't want to spend hours on debugging a test (like I did with the huge link() test), it should HELP me to debug PHP instead. Also, pretty please do not put tests for several functions in one test file. Things like "testing func1(), func2(), func3(), func4() and func5()" are not acceptable, these tests do not perform their primary function - they do not help the developers, the result is quite the contrary. On 21.07.2007 21:35, Raghubansh Kumar wrote: > kraghuba Sat Jul 21 17:35:37 2007 UTC > > Added files: (Branch: PHP_5_2) > /php-src/ext/standard/tests/file lstat_stat_variation1.phpt > lstat_stat_variation2.phpt > lstat_stat_variation3.phpt > lstat_stat_variation4.phpt > lstat_stat_variation5.phpt > lstat_stat_variation6.phpt > Log: > New testcases for lstat() and stat() functions > > -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- with Regards, Raghubansh