Development

/tags/RELEASE_0_6_2/pakefile.php

You must first sign up to be able to contribute.

root/tags/RELEASE_0_6_2/pakefile.php

Revision 1151, 6.0 kB (checked in by fabien, 2 years ago)

fixed unit testing for windows users (patch from RoVeRT)

Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004, 2005 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * @package    symfony
13  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
14  * @version    SVN: $Id$
15  */
16
17 /**
18  * Pakefile.
19  *
20  * @package    symfony
21  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
22  * @version    SVN: $Id$
23  */
24
25 pake_import('pear');
26
27 pake_desc('launch symfony test suite');
28 pake_task('alltests');
29
30 pake_desc('release a new symfony version');
31 //pake_task('release', 'alltests');
32
33 pake_task('release');
34
35 $sf_symfony_lib_dir = dirname(__FILE__).'/lib';
36
37 // YAML support
38 if (!function_exists('syck_load'))
39 {
40   require_once($sf_symfony_lib_dir.'/util/Spyc.class.php');
41 }
42 require_once($sf_symfony_lib_dir.'/util/sfYaml.class.php');
43
44 // cache support
45 require_once($sf_symfony_lib_dir.'/cache/sfCache.class.php');
46 require_once($sf_symfony_lib_dir.'/cache/sfFileCache.class.php');
47
48 // config support
49 require_once($sf_symfony_lib_dir.'/config/sfConfigCache.class.php');
50 require_once($sf_symfony_lib_dir.'/config/sfConfigHandler.class.php');
51 require_once($sf_symfony_lib_dir.'/config/sfYamlConfigHandler.class.php');
52 require_once($sf_symfony_lib_dir.'/config/sfAutoloadConfigHandler.class.php');
53 require_once($sf_symfony_lib_dir.'/config/sfRootConfigHandler.class.php');
54
55 // basic exception classes
56 require_once($sf_symfony_lib_dir.'/exception/sfException.class.php');
57 require_once($sf_symfony_lib_dir.'/exception/sfAutoloadException.class.php');
58 require_once($sf_symfony_lib_dir.'/exception/sfCacheException.class.php');
59 require_once($sf_symfony_lib_dir.'/exception/sfConfigurationException.class.php');
60 require_once($sf_symfony_lib_dir.'/exception/sfParseException.class.php');
61
62 // utils
63 require_once($sf_symfony_lib_dir.'/util/sfParameterHolder.class.php');
64
65 function __autoload($class)
66 {
67   static $loaded;
68
69   if (!$loaded)
70   {
71     // load the list of autoload classes
72     include_once(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/autoload.yml'));
73
74     $loaded = true;
75   }
76
77   $classes = sfConfig::get('sf_class_autoload', array());
78
79   if (!isset($classes[$class]))
80   {
81     $error = sprintf('Autoloading of class "%s" failed.', $class);
82     throw new pakeException($error);
83   }
84   else
85   {
86     require_once($classes[$class]);
87   }
88 }
89
90 function run_alltests($task, $args)
91 {
92   set_include_path(
93     dirname(__FILE__).'/lib'.PATH_SEPARATOR.
94     get_include_path()
95   );
96
97   // initialize our test environment
98   require_once(dirname(__FILE__).'/lib/util/sfToolkit.class.php');
99   sfToolkit::clearDirectory('/tmp/symfonytest');
100   $root_dir = tempnam('/tmp/symfonytest', 'tmp');
101   unlink($root_dir);
102   $tmp_dir = $root_dir.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true));
103   if (!is_dir($tmp_dir))
104   {
105     pake_mkdirs($tmp_dir, 0777);
106   }
107
108   require_once(dirname(__FILE__).'/lib/config/sfConfig.class.php');
109   sfConfig::add(array(
110     'sf_root_dir'         => $tmp_dir,
111     'sf_app'              => 'test',
112     'sf_environment'      => 'test',
113     'sf_debug'            => true,
114     'sf_symfony_lib_dir'  => dirname(__FILE__).'/lib',
115     'sf_symfony_data_dir' => dirname(__FILE__).'/data',
116     'sf_test'             => false,
117     'sf_version'          => 'test',
118   ));
119   pake_mkdirs($tmp_dir.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.'test'.DIRECTORY_SEPARATOR.'modules');
120   require_once(dirname(__FILE__).'/data/config/constants.php');
121   require_once(dirname(__FILE__).'/lib/util/sfContext.class.php');
122
123   pake_import('simpletest', false);
124
125   pakeSimpletestTask::run_test($task, $args);
126
127   // cleanup our test enviroment
128   sfToolkit::clearDirectory($tmp_dir);
129   rmdir($tmp_dir);
130   rmdir($root_dir);
131 }
132
133 function run_create_pear_package($task, $args)
134 {
135   if (!isset($args[0]))
136   {
137     throw new Exception('you must provide pake version to release');
138   }
139
140   $version    = $args[0];
141   $stability  = $args[1];
142
143   // create a pear package
144   print 'create pear package for version "'.$version."\"\n";
145
146   try
147   {
148     @pake_remove('package.xml', getcwd());
149   }
150   catch (Exception $e)
151   {
152   }
153   pake_copy(getcwd().'/package.xml.tmpl', getcwd().'/package.xml');
154
155   // add class files
156   $finder = pakeFinder::type('file')->prune('.svn')->discard('.svn')->relative();
157   $xml_classes = '';
158   $dirs = array('lib' => 'php', 'data' => 'data');
159   foreach ($dirs as $dir => $role)
160   {
161     $class_files = $finder->in($dir);
162     foreach ($class_files as $file)
163     {
164       $xml_classes .= '<file role="'.$role.'" baseinstalldir="symfony" install-as="'.$file.'" name="'.$dir.'/'.$file.'" />'."\n";
165     }
166   }
167
168   // replace tokens
169   pake_replace_tokens('package.xml', getcwd(), '##', '##', array(
170     'SYMFONY_VERSION' => $version,
171     'CURRENT_DATE'    => date('Y-m-d'),
172     'CLASS_FILES'     => $xml_classes,
173     'STABILITY'       => $stability,
174   ));
175   pakePearTask::run_pear($task, $args);
176   pake_remove('package.xml', getcwd());
177 }
178
179 function run_release($task, $args)
180 {
181   if (!isset($args[0]))
182   {
183     throw new Exception('you must provide version prefix (0.5 for beta release or 0.6.0 for stable release)');
184   }
185
186   if (!isset($args[1]))
187   {
188     throw new Exception('you must provide stability status (alpha/beta/stable)');
189   }
190
191   $stability = $args[1];
192
193   if ($stability == 'beta' || $stability == 'alpha')
194   {
195     $version_prefix = $args[0];
196
197     $result = pake_sh('svn status -u '.getcwd());
198
199     if (preg_match('/(\d+)\s*$/is', $result, $match))
200     {
201       $version = $match[1];
202     }
203
204     if (!isset($version))
205     {
206       throw new Exception('unable to find last svn revision');
207     }
208
209     // make a PEAR compatible version
210     $version = $version_prefix.'.'.$version;
211   }
212   else
213   {
214     $version = $args[0];
215   }
216
217   if ($task->is_verbose())
218   {
219     print 'releasing symfony version "'.$version."\"\n";
220   }
221
222   $args[0] = $version;
223
224   run_create_pear_package($task, $args);
225
226   // copy .tgz as symfony-latest.tgz
227   pake_copy(getcwd().'/symfony-'.$version.'.tgz', getcwd().'/symfony-latest.tgz');
228 }
229
230 ?>
231
Note: See TracBrowser for help on using the browser.