# detecting bad --CLEAN-- sections

- Thread: https://externals.io/message/43718
- Original archive: https://news-web.php.net/php.internals/43718
- Started by Greg Beaver on 2009-04-16T13:25:23+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43718 — Greg Beaver — 2009-04-16T13:25:23+00:00

URL: https://externals.io/message/43718#43718

hi,

I've noticed that it is very difficult to tell if your --CLEAN--
sections are actually working, so I wonder if it might be possible to
brainstorm ways of fixing this.

A couple of options come to mind that could be considered

- append this code to the end of the .clean.php file: ?><?php echo
"--CLEAN-- works"; ?> and capture the output, then check to make sure
that we see "--CLEAN-- works" in the output.  This would detect fatal
errors (which is the most common problem I find, especially when a
--CLEAN-- section includes a helper file).
- add a --REMOVEFILES--/--REMOVEDIRS-- section where one can specify
relative paths to files or whole directories that should be nixed, and
have run-tests do the removal

The most common usage for --CLEAN-- is to remove files, so I like the
second option personally.

Thanks,
Greg

---

## #43750 — zoe.slattery@googlemail.com — 2009-04-21T19:21:01+00:00

URL: https://externals.io/message/43718#43750 · In reply to: #43718

Greg Beaver wrote:
> hi,
>
> I've noticed that it is very difficult to tell if your --CLEAN--
> sections are actually working, so I wonder if it might be possible to
> brainstorm ways of fixing this.
>   
Yes, I found the same thing and fixed 40 tests under ext/standard/tests 
last week - in PHP53. Tedious work.
> A couple of options come to mind that could be considered
>
> - append this code to the end of the .clean.php file: ?><?php echo
> "--CLEAN-- works"; ?> and capture the output, then check to make sure
> that we see "--CLEAN-- works" in the output.  This would detect fatal
> errors (which is the most common problem I find, especially when a
> --CLEAN-- section includes a helper file).
> - add a --REMOVEFILES--/--REMOVEDIRS-- section where one can specify
> relative paths to files or whole directories that should be nixed, and
> have run-tests do the removal
>   
In the new run-tests code (http://cvs.php.net/viewvc.cgi/phpruntests/) 
we just check and warn if there is *any* output from executing the CLEAN 
section. This works in the sense that it's how I found all the messed up 
tests.

If you want to talk about other requirements for that code I think 
php-qa is the right place to do it. By the way, - CLEAN-- sections 
aren't the aren't the only problems. I've found a few sections called 
--SKIP--, which of course do nothing :-).

I  started a requirements page for the new code, here 
wiki.php.net/qa/runtests, but I think it's better to discuss on the list 
before adding there.

Zoe

---

## #43753 — johannes@php.net — 2009-04-21T22:45:26+00:00

URL: https://externals.io/message/43718#43753 · In reply to: #43718

> - add a --REMOVEFILES--/--REMOVEDIRS-- section where one can specify
> relative paths to files or whole directories that should be nixed, and
> have run-tests do the removal

Then the filename might still be wrong, and I think a more flexible
option might be nice for database test for instance where one wants to
delete temporary tables/procedures/... ... while doing that in a clean
section might be a pain as it is a third php process and third database
connection per test (skipif, file, clean) Not that I have a good
proposal either ;-)

johannes
