Forum OpenACS Development: Re: Watching files, new solutions

Collapse
Posted by Jeff Davis on
Another thing we could do is to check the file is parsable before reloading.

Here is a useful tcl script that walks through all the tcl files and checks if they parse properly (in the [info complete] sense at least)...

ad_page_contract {
    qa.tcl 
Check Tcl files for parsability

    Output streamed.

    @author Jeff Davis (davis@xarg.net)
    @creation-date 2003-12-01
    @cvs-id $Id$
} {
    {package:trim,optional {}}
}

ReturnHeaders

# couple of local helper procs 
proc ::tcl_p {file} { 
    return [expr [string match {*.tcl} $file] || [file isdirectory $file]]
}

proc bel {file} {
    return "<b>$file</b>(<a href=\"e?file=$file\">edit</a>)"
}

set startdir [acs_root_dir]/packages/$package

ns_write "Checks starting from $startdir<br />"

ns_write "Checking that the Tcl files parse...<br /><br />"

set checked 0
foreach file [ad_find_all_files -check_file_func ::tcl_p $startdir] { 
    incr checked 

    # Check that the file parses
    set fp [open $file "r"]
    set data [read $fp]
    close $fp

    if {![info complete $data]} {
        ns_write "<br />Parse Error: [bel $file]<br />"
    } else {
        #ns_write "$file "
    }
}
ns_write "Done checking files, did $checked<br /><br />"
Collapse
Posted by Malte Sussdorff on
Could we add scripts like yours to the monitoring package. Or developer support?
Collapse
Posted by Jeff Davis on
yes
Collapse
Posted by Joel Aufrecht on
I have added it to automated-testing in acs-tcl as acs_tcl__all_tcl_files_parse_p, in HEAD.  I dumbed it down a bit:

1) No support for testing only a sub-tree.  Maybe we should somehow make this a standard auto-test per-package instead of a single global?

2) Killed the link to the file since it didn't the original coded link didn't work for me and building a link to api-doc looked non-trivial.

3) I think we are going to need to get some conventions/support/documentation for differentiating between global tests like this, feature-specific regression tests, etc.  acs-automated-testing has some built-in categorization which we're not really using and we should tackle that in 5.1 as we add adp/tcl testing through tclwebtest.

Collapse
Posted by Tilmann Singer on
I never had troubles with the existing mechanism either. This script helps me find errors when tail'ing the error log by colorizing it and putting errors in bold red:

https://openacs.org/storage/file?file_id=151462

A few Shift-PGUP at most quickly reveal the source of any errors after a reload of the offending page.