Hey Jeremy,

Good work, I applied the patch locally and gave a very brief test. It
seems to work fine for running the agavi unit tests. But, when I
attempt to run the unit tests on one of my projects, it cant determine
where the project dir is. Eg:
Execution of target "test" failed for the following reason:
/var/www/sites/agavi/src/build.xml:41:32: Unable to determine the
location of the project directory based on: /var/www/sites/cmd5

cmd5 is the project dir, it use to be able to assume that by the
existence of cmd5/webapp (IIRC).

Didnt have time to dig into it to figure out what the fix would be, though.

-Mike

On 10/6/05, Jeremy Perrin <[EMAIL PROTECTED]> wrote:
> I modified the build.xml to allow for a build.properties file. Now you
> can specify
>
> agavi.webapp.dir = /RelativePathOffProjectDir
> agavi.www.dir = /RelativePathOffProjectDir
> agavi.tests.dir = /RelativePathOffProjectDir
>
> the change is backward compatible, if no build.properties file exists
> then the standard "webapp", "www", and "tests" directories are used
>
> the Patch is Attached.
>
> Jeremy Perrin
>
>
>
> Index: build.xml
> ===================================================================
> --- build.xml   (revision 261)
> +++ build.xml   (working copy)
> @@ -19,63 +19,74 @@
>         <taskdef classname="${agavi.dir}.buildtools.phing.AgaviFixPathsTask" 
> name="fixpaths"/>
>         <taskdef 
> classname="${agavi.dir}.buildtools.phing.AgaviListModulesTask" 
> name="listModules"/>
>
> -       <property name="webapp.dir" value=""/>
> -       <property name="tests.dir" value=""/>
> +       <target name="buildpropescheck">
> +         <available file="${project.dir}/build.properties" 
> property="configure.check"/>
> +       </target>
>
> -  <!-- fileset for -dist files -->
> -  <fileset dir="." id="distfiles">
> +       <target name="configure" depends="buildpropescheck">
> +               <echo msg="Loading project-specific properties from 
> ${project.dir}/build.properties"/>
> +               <property file="${project.dir}/build.properties"/>
> +               <property name="agavi.webapp.dir" value="/webapp" 
> override="false"/>
> +               <property name="agavi.www.dir" value="/www" override="false"/>
> +               <property name="agavi.tests.dir" value="/tests" 
> override="false"/>
> +       </target>
> +
> +       <!-- fileset for -dist files-->
> +       <fileset dir="." id="distfiles">
>                 <include name="**/*-dist"/>
> -  </fileset>
> -
> +       </fileset>
> +
>         <!-- Unit Testing -->
>         <target name="test" description="run unit tests">
> -               <fixpaths base="${project.dir}" testing="true"/>
> +               <fixpaths base="${project.dir}" webapp="${agavi.webapp.dir}" 
> testing="true"/>
>                 <property name="agavidir" value="${agavi.dir}" />
> -         <property name="testdir" value="${tests.dir}"  />
> -         <property name="from" value=""  />
> -       <property name="reporter" value="text"  />
> -       <property name="outfile" value=""  />
> -               <agavitest exit="true" testdir="${tests.dir}" 
> agavidir="${agavi.dir}" startpoint="${from}" reporter="${reporter}" 
> outfile="${outfile}"/>
> +               <property name="testdir" value="${agavi.tests.dir}"  />
> +               <property name="from" value=""  />
> +               <property name="reporter" value="text"  />
> +               <property name="outfile" value=""  />
> +               <agavitest exit="true" testdir="${agavi.tests.dir}" 
> agavidir="${agavi.dir}" startpoint="${from}" reporter="${reporter}" 
> outfile="${outfile}"/>
>         </target>
>
>         <!-- Project creation -->
> -       <target name="project" description="create a new project">
> +       <target name="project" depends="configure" description="create a new 
> project">
>                 <input propertyname="project.dir" promptChar="?" 
> message="Full path to your new project (no trailing slash!)"/>
>                 <mkdir dir="${project.dir}"/>
> -               <fixpaths base="${project.dir}" new="true"/>
> -               <echo msg="project dir: ${project.dir}, webapp dir: 
> ${webapp.dir}, tests dir: ${tests.dir}"/>
> +               <fixpaths base="${project.dir}" webapp="${agavi.webapp.dir}" 
> tests="${agavi.tests.dir}" new="true"/>
> +               <echo msg="project dir: ${project.dir}"/>
> +               <echo msg="webapp dir: ${agavi.webapp.dir}"/>
> +               <echo msg="tests dir: ${agavi.tests.dir}"/>
>                 <mkdir dir="${project.dir}"/>
> -               <mkdir dir="${webapp.dir}"/>
> -               <mkdir dir="${project.dir}/www"/>
> -               <copy file="buildtools/code_templates/index.php.tmpl" 
> tofile="${project.dir}/www/index.php">
> +               <mkdir dir="${agavi.webapp.dir}"/>
> +               <mkdir dir="${project.dir}/${agavi.www.dir}"/>
> +               <copy file="buildtools/code_templates/index.php.tmpl" 
> tofile="${project.dir}/${agavi.www.dir}/index.php">
>                         <filterchain>
>                                 <replacetokens begintoken="%%" endtoken="%%">
> -                                       <token key="PATH_TO_AGAVI" 
> value="${agavi.dir}"/> <!-- was project.basedir -->
> -                                       <token key="PATH_TO_PROJECT" 
> value="${webapp.dir}"/>
> +                                       <token key="PATH_TO_AGAVI" 
> value="${agavi.dir}"/>
> +                                       <token key="PATH_TO_PROJECT" 
> value="${agavi.webapp.dir}"/>
>                                 </replacetokens>
>                         </filterchain>
>                 </copy>
> -               <mkdir dir="${project.dir}/www/modpub"/>
> -               <mkdir dir="${webapp.dir}/cache"/>
> -               <copy file="buildtools/code_templates/config.php.tmpl" 
> tofile="${webapp.dir}/config.php">
> +               <mkdir dir="${project.dir}/${agavi.www.dir}/modpub"/>
> +               <mkdir dir="${agavi.webapp.dir}/cache"/>
> +               <copy file="buildtools/code_templates/config.php.tmpl" 
> tofile="${agavi.webapp.dir}/config.php">
>                         <filterchain>
>                                 <replacetokens begintoken="%%" endtoken="%%">
>                                         <token key="PATH_TO_AGAVI" 
> value="${agavi.dir}"/>
> -                                       <token key="PATH_TO_PROJECT" 
> value="${webapp.dir}"/>
> +                                       <token key="PATH_TO_PROJECT" 
> value="${agavi.webapp.dir}"/>
>                                 </replacetokens>
>                         </filterchain>
>                 </copy>
> -               <mkdir dir="${webapp.dir}/config"/>
> -               <copy todir="${webapp.dir}/config">
> +               <mkdir dir="${agavi.webapp.dir}/config"/>
> +               <copy todir="${agavi.webapp.dir}/config">
>                         <fileset dir="buildtools/code_templates/config">
>                                 <include name="*.ini"/>
>                                 <include name="*.conf"/>
>                         </fileset>
>                 </copy>
> -               <mkdir dir="${webapp.dir}/lib"/>
> -               <mkdir dir="${webapp.dir}/lib/models"/>
> -               <mkdir dir="${webapp.dir}/modules"/>
> -               <mkdir dir="${webapp.dir}/templates"/>
> +               <mkdir dir="${agavi.webapp.dir}/lib"/>
> +               <mkdir dir="${agavi.webapp.dir}/lib/models"/>
> +               <mkdir dir="${agavi.webapp.dir}/modules"/>
> +               <mkdir dir="${agavi.webapp.dir}/templates"/>
>
>                 <phingcall target="projecttests" />
>
> @@ -85,26 +96,25 @@
>
>         <!-- create tests directory structure which mimics the webapp 
> structure -->
>         <target name="projecttests" description="create tests structure for 
> project">
> -               <fixpaths base="${project.dir}"/>
> -               <mkdir dir="${tests.dir}" />
> -               <mkdir dir="${tests.dir}/lib" />
> -               <mkdir dir="${tests.dir}/lib/models" />
> -               <mkdir dir="${tests.dir}/modules" />
> -               <copy file="buildtools/test_setup.php" 
> tofile="${tests.dir}/test_setup.php" overwrite="true"/>
> +               <mkdir dir="${agavi.tests.dir}" />
> +               <mkdir dir="${agavi.tests.dir}/lib" />
> +               <mkdir dir="${agavi.tests.dir}/lib/models" />
> +               <mkdir dir="${agavi.tests.dir}/modules" />
> +               <copy file="buildtools/test_setup.php" 
> tofile="${agavi.tests.dir}/test_setup.php" overwrite="true"/>
>         </target>
>
>         <!-- Module creation -->
>         <!-- create a new module in an existing project -->
> -       <target name="module" description="create a new module in an existing 
> project.">
> -               <fixpaths base="${project.dir}"/>
> -               <available file="${webapp.dir}/modules" type="dir" 
> property="is_webapp" value="true"/>
> -               <fail unless="is_webapp" message="Must be called in the root 
> of a webapp directory. (${webapp.dir})"/>
> +       <target name="module" depends="configure" description="create a new 
> module in an existing project.">
> +               <fixpaths base="${project.dir}" webapp="${agavi.webapp.dir}" 
> tests="${agavi.tests.dir}"/>
> +               <available file="${agavi.webapp.dir}/modules" type="dir" 
> property="is_webapp" value="true"/>
> +               <fail unless="is_webapp" message="Must be called in the root 
> of a webapp directory. (${agavi.webapp.dir})"/>
>                 <input propertyname="module" promptChar="?" message="Module 
> Name"/>
>                 <phingcall target="buildmodule"/>
>         </target>
>
>         <target name="buildmodule">
> -               <property name="module.dir" 
> value="${webapp.dir}/modules/${module}"/>
> +               <property name="module.dir" 
> value="${agavi.webapp.dir}/modules/${module}"/>
>                 <mkdir dir="${module.dir}"/>
>                 <mkdir dir="${module.dir}/actions"/>
>                 <mkdir dir="${module.dir}/config"/>
> @@ -130,8 +140,8 @@
>         </target>
>
>         <target name="buildmoduletests">
> -               <fixpaths base="${project.dir}"/>
> -               <property name="moduletests.dir" 
> value="${tests.dir}/modules/${module}"/>
> +               <fixpaths base="${project.dir}" webapp="${agavi.webapp.dir}"/>
> +               <property name="moduletests.dir" 
> value="${agavi.tests.dir}/modules/${module}"/>
>                 <mkdir dir="${moduletests.dir}"/>
>                 <available file="${moduletests.dir}" type="dir" 
> property="has_tests" value="true"/>
>                 <fail unless="has_tests" message="Project's tests directory 
> not found."/>
> @@ -142,19 +152,19 @@
>         </target>
>
>         <!-- Action creation -->
> -       <target name="action" description="create a new action">
> -               <fixpaths base="${project.dir}" defaultmodule="true"/>
> +       <target name="action" depends="configure" description="create a new 
> action">
> +               <fixpaths base="${project.dir}" webapp="${agavi.webapp.dir}" 
> tests="${agavi.tests.dir}" defaultmodule="true"/>
>                 <!--
>                 <available file="${module.dir}/config/module.ini" 
> property="is_module" value="true"/>
>                 <fail unless="is_module" message="Must be called in the root 
> of a module directory."/>
>                 -->
> -               <listModules webapp="${webapp.dir}" 
> property="current.modules"/>
> +               <listModules webapp="${agavi.webapp.dir}" 
> property="current.modules"/>
>
>                 <input propertyname="module" promptChar="?" 
> validArgs="${current.modules}" defaultValue="${default.module}" message="Make 
> the action for which module? "/>
>                 <input propertyname="action" promptChar="?" 
> defaultValue="Index" message="Action Name"/>
>                 <phingcall target="buildaction">
> -                       <property name="module.dir" 
> value="${webapp.dir}/modules/${module}"/>
> -                       <property name="moduletests.dir" 
> value="${tests.dir}/modules/${module}"/>
> +                       <property name="module.dir" 
> value="${agavi.webapp.dir}/modules/${module}"/>
> +                       <property name="moduletests.dir" 
> value="${agavi.tests.dir}/modules/${module}"/>
>                 </phingcall>
>         </target>
>
> @@ -168,7 +178,7 @@
>                         </filterchain>
>                 </copy>
>                 <phingcall target="buildactiontests">
> -                       <property name="moduletests.dir" 
> value="${tests.dir}/modules/${module}"/>
> +                       <property name="moduletests.dir" 
> value="${agavi.tests.dir}/modules/${module}"/>
>                 </phingcall>
>                 <input propertyname="views" promptChar="?" 
> defaultValue="Success,Error" message="Views for ${action} (no whitespace, 
> comma seperated)"/>
>                 <foreach list="${views}" param="view" target="buildview"/>
> @@ -190,7 +200,7 @@
>         </target>
>
>         <!-- View creation -->
> -       <target name="buildview">
> +       <target name="buildview" depends="configure">
>                 <copy file="buildtools/code_templates/View.class.php.tmpl" 
> tofile="${module.dir}/views/${action}${view}View.class.php">
>                         <filterchain>
>                                 <replacetokens begintoken="%%" endtoken="%%">
> @@ -202,7 +212,7 @@
>                 </copy>
>                 <touch file="${module.dir}/templates/${action}${view}.php"/>
>                 <phingcall target="buildviewtests">
> -                       <property name="moduletests.dir" 
> value="${tests.dir}/modules/${module}"/>
> +                       <property name="moduletests.dir" 
> value="${agavi.tests.dir}/modules/${module}"/>
>                 </phingcall>
>         </target>
>
> @@ -223,7 +233,7 @@
>         </target>
>
>         <!-- Model creation -->
> -       <target name="model" description="create a new model">
> +       <target name="model" depends="configure" description="create a new 
> model">
>                 <input propertyname="model" promptChar="?" 
> defaultValue="${module}" message="Model Name"/>
>                 <phingcall target="buildmodel"/>
>         </target>
> @@ -238,7 +248,7 @@
>                         </filterchain>
>                 </copy>
>                 <phingcall target="buildmodeltests">
> -                       <property name="moduletests.dir" 
> value="${tests.dir}/modules/${module}"/>
> +                       <property name="moduletests.dir" 
> value="${agavi.tests.dir}/modules/${module}"/>
>                 </phingcall>
>         </target>
>
> Index: buildtools/phing/AgaviFixPathsTask.php
> ===================================================================
> --- buildtools/phing/AgaviFixPathsTask.php      (revision 261)
> +++ buildtools/phing/AgaviFixPathsTask.php      (working copy)
> @@ -1,6 +1,8 @@
>  <?php
>  class AgaviFixPathsTask extends Task {
>         private $base,
> +                                       $webapp = '/webapp',
> +                                       $tests = '/tests',
>                                         $depth=5,
>                                         $newproject = false,
>                                         $parseModulePath = false,
> @@ -9,7 +11,15 @@
>         public function setBase($base) {
>                 $this->base = $base;
>         }
> -
> +
> +       public function setWebapp($dir) {
> +               $this->webapp = $dir;
> +       }
> +
> +       public function setTests($dir) {
> +               $this->tests = $dir;
> +       }
> +
>         public function setDepth($depth) {
>                 $this->depth = (int) $depth;
>         }
> @@ -39,7 +49,11 @@
>                 return $module;
>         }
>
> -       private function getDir($pattern = '/webapp') {
> +       private function getDir($pattern = '') {
> +               //Because the Webapp.Dir Property is change during execution, 
> only grab the last directory
> +               //It is changed from a relative path to a exact path. This is 
> only done if the $pattern isn't
> +               //passed into the function
> +               $pattern = (strlen($pattern) <= 0) ? substr($this->webapp, 
> strrpos($this->webapp, '/')) : $pattern;
>                 if ($this->newproject || file_exists($this->base . $pattern)) 
> {
>                         return realpath($this->base);
>                 }
> @@ -48,7 +62,7 @@
>                                 return realpath($this->base . 
> str_repeat('/../',$i));
>                         }
>                 }
> -               return ($this->testing && $pattern == '/webapp' ? 
> $this->getDir('/src/agavi.php') : false);
> +               return ($this->testing && $pattern == $this->webapp ? 
> $this->getDir('/src/agavi.php') : false);
>         }
>
>         public function main() {
> @@ -56,8 +70,8 @@
>                 if ($pdir) {
>                         echo "Project dir: $pdir\n";
>                         $this->project->setProperty('project.dir', $pdir);
> -                       $this->project->setProperty('webapp.dir', 
> realpath($pdir) . '/webapp');
> -                       $this->project->setProperty('tests.dir', 
> realpath($pdir) . '/tests');
> +                       $this->project->setProperty('agavi.webapp.dir', 
> realpath($pdir) . $this->webapp);
> +                       $this->project->setProperty('agavi.tests.dir', 
> realpath($pdir) . $this->tests);
>                         if ($this->parseModulePath) {
>                                 $this->project->setProperty('default.module', 
> $this->getModule());
>                         }
> Index: buildtools/phing/AgaviTestTask.php
> ===================================================================
> --- buildtools/phing/AgaviTestTask.php  (revision 261)
> +++ buildtools/phing/AgaviTestTask.php  (working copy)
> @@ -1,6 +1,7 @@
>  <?php
>
>  class AgaviTestTask extends Task {
> +
>         private $agavidir,
>                                         $testdir = 'tests',
>                                         $reporter = 'text',
> @@ -9,6 +10,10 @@
>                                         $outfile = '',
>                                         $exit = false;
>
> +       public function setWebapp($dir = 'webapp') {
> +               $this->base_include[1] = $dir;
> +       }
> +
>         public function setAgavidir($dir)
>         {
>                 $this->agavidir = (string) $dir;
>
>
> _______________________________________________
> agavi-dev mailing list
> [email protected]
> http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev
>
>
>
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to