示例#1
0
function delete($details)
{
    $conn = new Connection("auto");
    $query = new Build();
    $result = $query->delete($conn->grab_conn(), $details, "close");
    return $result;
}
示例#2
0
 public function testBuildReplaceExampleProject()
 {
     $build = new Build();
     $build->build(__DIR__ . '/../_fixtures/example-replace');
     $bazNamespaces = (include __DIR__ . '/../_fixtures/example-replace/baz/vendor/composer/autoload_namespaces.php');
     $this->assertCount(2, $bazNamespaces);
     $this->assertEquals(array('Baz\\', 'Bar\\'), array_keys($bazNamespaces));
 }
示例#3
0
 public function deregister(Build $build)
 {
     $file = $this->baseDir . DIRECTORY_SEPARATOR . $build->getName();
     if (file_exists($file)) {
         unlink($file);
         return true;
     }
     return false;
 }
示例#4
0
 public function testBuildGetDate()
 {
     $retval = 0;
     $build = new Build();
     $build->Id = 1;
     $build->ProjectId = 1;
     $build->Filled = true;
     $row = pdo_single_row_query('SELECT nightlytime FROM project WHERE id=1');
     $original_nightlytime = $row['nightlytime'];
     // Test the case where the project's start time is in the evening.
     pdo_query("UPDATE project SET nightlytime = '20:00:00' WHERE id=1");
     $build->StartTime = date('Y-m-d H:i:s', strtotime('2009-02-23 19:59:59'));
     $expected_date = '2009-02-23';
     $date = $build->GetDate();
     if ($date !== $expected_date) {
         $this->fail("Evening case: expected {$expected_date}, found {$date}");
         $retval = 1;
     }
     $build->StartTime = date('Y-m-d H:i:s', strtotime('2009-02-23 20:00:00'));
     $expected_date = '2009-02-24';
     $build->NightlyStartTime = false;
     $date = $build->GetDate();
     if ($date !== $expected_date) {
         $this->fail("Evening case: expected {$expected_date}, found {$date}");
         $retval = 1;
     }
     // Test the case where the project's start time is in the morning.
     pdo_query("UPDATE project SET nightlytime = '09:00:00' WHERE id=1");
     $build->StartTime = date('Y-m-d H:i:s', strtotime('2009-02-23 08:59:59'));
     $expected_date = '2009-02-22';
     $build->NightlyStartTime = false;
     $date = $build->GetDate();
     if ($date !== $expected_date) {
         $this->fail("Morning case: expected {$expected_date}, found {$date}");
         $retval = 1;
     }
     $build->StartTime = date('Y-m-d H:i:s', strtotime('2009-02-23 09:00:00'));
     $expected_date = '2009-02-23';
     $build->NightlyStartTime = false;
     $date = $build->GetDate();
     if ($date !== $expected_date) {
         $this->fail("Morning case: expected {$expected_date}, found {$date}");
         $retval = 1;
     }
     pdo_query("UPDATE project SET nightlytime = '{$original_nightlytime}' WHERE id=1");
     if ($retval === 0) {
         $this->pass('Tests passed');
     }
     return $retval;
 }
 public function saveConfig()
 {
     //       C('URL_MODEL',2);
     //动态生成控制器类/模型类
     Build::buildController('Home', 'UserDisplay');
     Build::buildModel('User', 'UserDisplay');
 }
 public function testBuildDeletePost()
 {
     $build = Build::find(2);
     $data = array('confirm-delete' => '1');
     $response = $this->call('POST', '/modpack/build/' . $build->id . '?action=delete', $data);
     $this->assertRedirectedTo('modpack/view/' . $build->modpack->id);
 }
示例#7
0
 static function inbetweenBuilds($regression)
 {
     $build = $regression->build();
     $run = $build->run();
     $mode_id = $build->mode_id();
     $machine_id = $run->machine_id();
     $sortOrder = $run->sort_order();
     $prevSortOrder = $regression->prev_build()->run()->sort_order();
     $builds = array();
     for ($i = $prevSortOrder + 1; $i < $sortOrder; $i++) {
         $run_i = Run::withMachineAndSortOrder($machine_id, $i);
         if (!$run_i->isFinished()) {
             continue;
         }
         $build = Build::withRunAndMode($run_i->id, $mode_id);
         if (!$build) {
             continue;
         }
         if (count($build->scores()) == 0) {
             continue;
         }
         $builds[] = $build;
     }
     return $builds;
 }
示例#8
0
 public static function start()
 {
     //注册自动加载类函数
     spl_autoload_register('self::autoload');
     //导入公用的函数
     include THINK_PATH . 'Common/functions.php';
     //导入通用的function函数
     if (is_file(COMMON_PATH . 'Common/function.php')) {
         include COMMON_PATH . 'Common/function.php';
     }
     //导入通用的配置文件
     C(include THINK_PATH . 'Conf/convention.php');
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 检查应用目录结构 如果不存在则自动创建
     if (C('CHECK_APP_DIR')) {
         if (!is_dir(LOG_PATH)) {
             // 检测应用目录结构
             Build::checkDir();
         }
     }
     // 定义当前请求的系统常量
     define('NOW_TIME', $_SERVER['REQUEST_TIME']);
     define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
     define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
     define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
     //路由解析
     self::dispatch();
     define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')]) ? true : false);
     //初始化session
     session(C('SESSION_OPTIONS'));
     //执行应用程序
     self::exec();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('modpacks')->delete();
     $testmodpack = Modpack::create(array('name' => 'TestModpack', 'slug' => 'testmodpack', 'icon' => false, 'icon_md5' => md5_file(public_path() . '/resources/default/icon.png'), 'icon_url' => URL::asset('/resources/default/icon.png'), 'logo' => false, 'logo_md5' => md5_file(public_path() . '/resources/default/logo.png'), 'logo_url' => URL::asset('/resources/default/logo.png'), 'background' => false, 'background_md5' => md5_file(public_path() . '/resources/default/background.jpg'), 'background_url' => URL::asset('/resources/default/background.jpg')));
     DB::table('builds')->delete();
     $testbuild = Build::create(array('modpack_id' => $testmodpack->id, 'version' => '1.0.0', 'minecraft' => '1.7.10', 'minecraft_md5' => 'e6b7a531b95d0c172acb704d1f54d1b3', 'min_java' => '1.7', 'min_memory' => '1024', 'is_published' => true));
 }
示例#10
0
 private static function findSortOrder($run, $mode_id, $revision)
 {
     $version_control = VersionControl::forMode($mode_id);
     $j = 0;
     while (True) {
         if ($j++ > 30) {
             throw new Exception("There shouldn't be too many runs in between");
         }
         if (!$run->isBuildInfoComplete()) {
             throw new Exception("Encountered an incomplete run.");
         }
         $build = Build::withRunAndMode($run->id, $mode_id);
         // We can safely ignore runs that have no results with the requested mode_id
         if (!$build) {
             $run = $run->next();
             continue;
         }
         // We skip to the next run, if revisions are the same.
         // To make sure that new runs are shown after existing ones.
         if ($version_control->equal($build->revision(), $revision)) {
             $run = $run->next();
             continue;
         }
         // Using version control take a peek if the revision
         // is later/earlier than this one.
         if ($version_control->isAfter($build->revision(), $revision)) {
             return $run->sort_order();
         }
         $run = $run->next();
     }
 }
 public function getIndex()
 {
     $builds = Build::where('is_published', '=', '1')->orderBy('updated_at', 'desc')->take(5)->get();
     $modversions = Modversion::whereNotNull('md5')->orderBy('updated_at', 'desc')->take(5)->get();
     $rawChangeLog = UpdateUtils::getLatestChangeLog();
     $changelogJson = array_key_exists('error', $rawChangeLog) ? $rawChangeLog : array_slice($rawChangeLog, 0, 10);
     return View::make('dashboard.index')->with('modversions', $modversions)->with('builds', $builds)->with('changelog', $changelogJson);
 }
示例#12
0
 private static function resolvePathes($projectName)
 {
     self::$projectPath = realpath(dirname(__FILE__) . "/../../{$projectName}");
     $abs = str_replace('\\', '/', self::$projectPath);
     $root = $_SERVER['DOCUMENT_ROOT'];
     $root = str_replace('\\', '/', $root);
     self::$projectURL = str_replace($root, '', $abs) . "/";
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('builds', function ($table) {
         $table->string('minecraft_md5')->default('');
     });
     $minecraft = MinecraftUtils::getMinecraft(true);
     foreach (Build::all() as $build) {
         $build->minecraft_md5 = $minecraft[$build->minecraft]->md5;
         $build->save();
     }
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('builds', function ($table) {
         $table->string('minecraft_md5');
     });
     $minecraft = $this->getMinecraft();
     $minecraft = (array) $minecraft;
     foreach (Build::all() as $build) {
         $build->minecraft_md5 = $minecraft[$build->minecraft]->md5;
         $build->save();
     }
 }
示例#15
0
 /** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
 {
     $output = '';
     if ($fieldset->getName() == 'Deploy') {
         foreach ($fieldset as $element) {
             // Default renderer would prepend
             $output .= $view->formRow($element, 'append') . "\n";
         }
     } else {
         $output .= parent::renderFieldset($view, $fieldset);
     }
     return $output;
 }
示例#16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     //$this->call('UserTableSeeder');
     $this->call('ModpackTableTestSeeder');
     $this->call('ModTableTestSeeder');
     $this->call('ClientTableTestSeeder');
     $this->call('KeyTableTestSeeder');
     DB::table('build_modversion')->delete();
     $testbuild = Build::find(1);
     //Add testmodversion to testbuild
     $testbuild->modversions()->attach(1);
 }
示例#17
0
 public static function start()
 {
     //注册AUTOLOAD方法
     spl_autoload_register('\\Core\\HF::autoload');
     //自动生成目录
     Build::checkDir();
     //加载项目下配置文件
     if (is_file(CONF_PATH . 'config.php')) {
         C(include CONF_PATH . 'config.php');
     }
     //运行应用
     App::run();
 }
示例#18
0
		function installMods($mods)
		{
			global $config, $db, $user, $auth, $template, $cache;
			global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
			
			$res = $db->sql_query(
				'SELECT style_name FROM ' . $table_prefix 
				. 'styles WHERE style_id = ' . $config['default_style']
			);
			$this->style = $db->sql_fetchfield('style_name');
			$build = Build::create();
			foreach ($mods as $modName)
				$build->addMod(Mod::create()->setName($modName));
			try {
				$deps = $build->getDependences('style');
			} catch (Exception $e) {
				return null;
			}			
			
			if ($deps && !in_array($this->style, $deps)) {
				return $build;
			} else {
				try {
					InstallAction::me()->setBuild($build)->run();
					file_put_contents(
						USER_DIR . DIRECTORY_SEPARATOR . '.htaccess',
						str_replace(
							$this->build->getHash(),
							$build->getHash(),
							file_get_contents(
								USER_DIR . DIRECTORY_SEPARATOR . '.htaccess'
							)
						)
					);
					
					file_put_contents(
						USER_DIR . DIRECTORY_SEPARATOR . 'nginx.rewrite',
						str_replace(
							$this->build->getHash(),
							$build->getHash(),
							file_get_contents(
								USER_DIR . DIRECTORY_SEPARATOR . 'nginx.rewrite'
							)
						)
					);
				} catch (Exception $e) {
					trigger_error($e->getMessage(),E_USER_WARNING);
				}
			}
			return $this;
		}
示例#19
0
文件: new.php 项目: xaizek/fragile
/**
 * @brief Schedules builders discovered in @p dir directory.
 *
 * @param buildset Parent buildset for newly created builds.
 * @param dir Directory to look for builders.
 * @param suffix Additional suffix for builders path (appended to @p dir).
 *
 * @returns Array of scheduler builder names.
 */
function scheduleBuilders($buildset, $dir, $suffix)
{
    $builders = [];
    $basePath = "{$dir}/{$suffix}";
    if (is_dir($basePath) && ($handle = opendir($basePath))) {
        while (($entry = readdir($handle)) !== false) {
            $path = "{$basePath}/{$entry}";
            if (!is_dir($path) && $entry != '.' && $entry != '..') {
                $builderName = "{$suffix}{$entry}";
                Build::create($buildset, $builderName);
                array_push($builders, $builderName);
            }
        }
        closedir($handle);
    }
    return $builders;
}
示例#20
0
文件: Build.php 项目: weijer/DIServer
 private static function buildAppServerDir($serverName)
 {
     // 没有创建的话自动创建
     if (!is_dir(DI_APP_PATH)) {
         mkdir(DI_APP_PATH, 0755, true);
     }
     if (is_writeable(DI_APP_PATH)) {
         Build::makeDirs();
         //生成基础目录
         Build::makeConfigs();
         //生成基础配置文件
         Build::makeFunctions();
         //生成基础函数文件
         Build::makeReloadHelper($serverName);
         //生成基础热重载类。
     } else {
         exit("应用目录[' . DI_APP_PATH . ']不可写,目录无法自动生成!\n请手动生成项目目录~");
     }
 }
示例#21
0
 // 实例化对象
 private static $_instance = array();
 /**
  * 应用程序初始化
  * @access public
  * @return void
  */
 public static function start()
 {
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoload');
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimefile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimefile)) {
         Storage::load($runtimefile);
     } else {
         if (Storage::has($runtimefile)) {
             Storage::unlink($runtimefile);
         }
         $content = '';
         // 读取应用模式
         $mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载应用模式配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(load_config($file)) : C($key, load_config($file));
         }
         // 读取当前应用模式对应的配置文件
         if ('common' != APP_MODE && is_file(CONF_PATH . 'config_' . APP_MODE . CONF_EXT)) {
             C(load_config(CONF_PATH . 'config_' . APP_MODE . CONF_EXT));
         }
         // 加载模式别名定义
         if (isset($mode['alias'])) {
             self::addMap(is_array($mode['alias']) ? $mode['alias'] : (include $mode['alias']));
         }
         // 加载应用别名定义文件
         if (is_file(CONF_PATH . 'alias.php')) {
             self::addMap(include CONF_PATH . 'alias.php');
         }
         // 加载模式行为定义
         if (isset($mode['tags'])) {
             Hook::import(is_array($mode['tags']) ? $mode['tags'] : (include $mode['tags']));
         }
         // 加载应用行为定义
         if (is_file(CONF_PATH . 'tags.php')) {
             // 允许应用增加开发模式配置定义
             Hook::import(include CONF_PATH . 'tags.php');
         }
         // 加载框架底层语言包
         L(include THINK_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
         if (!APP_DEBUG) {
             $content .= "\nnamespace { Think\\Think::addMap(" . var_export(self::$_map, true) . ");";
             $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(Hook::get(), true) . ');}';
             Storage::put($runtimefile, strip_whitespace('<?php ' . $content));
         } else {
             // 调试模式加载系统默认的配置文件
             C(include THINK_PATH . 'Conf/debug.php');
             // 读取应用调试配置文件
             if (is_file(CONF_PATH . 'debug' . CONF_EXT)) {
                 C(include CONF_PATH . 'debug' . CONF_EXT);
             }
         }
     }
     // 读取当前应用状态对应的配置文件
     if (APP_STATUS && is_file(CONF_PATH . APP_STATUS . CONF_EXT)) {
         C(include CONF_PATH . APP_STATUS . CONF_EXT);
     }
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 检查应用目录结构 如果不存在则自动创建
     if (C('CHECK_APP_DIR')) {
         $module = defined('BIND_MODULE') ? BIND_MODULE : C('DEFAULT_MODULE');
         if (!is_dir(APP_PATH . $module) || !is_dir(LOG_PATH)) {
             // 检测应用目录结构
             Build::checkDir($module);
         }
示例#22
0
// 加载基础文件
require __DIR__ . '/base.php';
require CORE_PATH . 'Loader.php';
// 注册自动加载
Loader::register();
// 注册错误和异常处理机制
register_shutdown_function('think\\Error::appShutdown');
set_error_handler('think\\Error::appError');
set_exception_handler('think\\Error::appException');
// 加载模式定义文件
$mode = (require MODE_PATH . APP_MODE . EXT);
// 加载模式别名定义
if (isset($mode['alias'])) {
    Loader::addMap(is_array($mode['alias']) ? $mode['alias'] : (include $mode['alias']));
}
// 加载模式配置文件
if (isset($mode['config'])) {
    is_array($mode['config']) ? Config::set($mode['config']) : Config::load($mode['config']);
}
// 加载模式行为定义
if (APP_HOOK && isset($mode['tags'])) {
    Hook::import(is_array($mode['tags']) ? $mode['tags'] : (include $mode['tags']));
}
// 自动生成
if (APP_AUTO_BUILD && is_file(APP_PATH . 'build.php')) {
    Build::run(include APP_PATH . 'build.php');
}
// 是否自动运行
if (APP_AUTO_RUN) {
    App::run();
}
 public function addBundle()
 {
     if (!Input::hasFile('ipa')) {
         exit(0);
     } else {
         $ipa = Input::file('ipa');
     }
     $payload = exec("unzip -l " . $ipa->getRealPath() . " | sed -e 's/ /\\n/g' | grep app/Info.plist | sed -e 's/Info.plist//g'");
     $default_icon = public_path() . "/images/default_icon.png";
     $fileSystem = new Filesystem();
     if (!$fileSystem->exists('/tmp/bundle')) {
         $fileSystem->makeDirectory('/tmp/bundle');
     }
     if (!$fileSystem->exists('/tmp/bundle/tmp')) {
         $fileSystem->makeDirectory('/tmp/bundle/tmp');
     }
     $path = "/tmp/bundle" . $ipa->getRealPath();
     if ($fileSystem->exists($path)) {
         $fileSystem->deleteDirectory($path);
     }
     $fileSystem->makeDirectory($path);
     $zip = new ZipArchive();
     $res = $zip->open($ipa->getRealPath());
     if ($res === TRUE) {
         $zip->extractTo($path);
         $zip->close();
     }
     $dirs = scandir($path);
     array_shift($dirs);
     array_shift($dirs);
     $APP_PATH = $path . "/" . $dirs[0];
     $dirs = scandir($APP_PATH);
     array_shift($dirs);
     array_shift($dirs);
     $APP_PATH = $APP_PATH . "/" . $dirs[0];
     $plist = CFPropertyList::getInstance();
     $plist->setFile($APP_PATH . "/Info.plist");
     $plist->load();
     $info = $plist->toArray();
     $name = $info['CFBundleName'];
     $build = isset($info['CFBundleVersion']) && array_key_exists("CFBundleVersion", $info) ? $info['CFBundleVersion'] : 1;
     $version = isset($info['CFBundleShortVersionString']) && array_key_exists("CFBundleShortVersionString", $info) ? $info['CFBundleShortVersionString'] : 0;
     if (array_key_exists("CFBundleIconFiles", $info)) {
         $icons = $info['CFBundleIconFiles'];
     } else {
         if (array_key_exists("CFBundleIcons", $info)) {
             $icons = $info["CFBundleIcons"]["CFBundlePrimaryIcon"]["CFBundleIconFiles"];
         } else {
             $icons = array();
         }
     }
     $bundle = $info['CFBundleIdentifier'];
     $label = $_POST['label'];
     if (!$fileSystem->exists(public_path() . '/builds')) {
         $fileSystem->makeDirectory(public_path() . '/builds');
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios')) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios');
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label);
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label . '/' . $version)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label . '/' . $version);
     }
     $icons_ready = array();
     foreach ($icons as $icon) {
         $img = "{$path}/tmp5646431.png";
         $icon = str_replace(".png", "", $icon) . ".png";
         $processor = PPngUncrush::getInstance();
         if (is_file("{$APP_PATH}/{$icon}")) {
             $processor->setFilePath("{$APP_PATH}/{$icon}");
             try {
                 $processor->decode($img . $icon);
             } catch (ErrorException $e) {
                 $img = $default_icon;
                 $icon = "";
             }
             $sz = getimagesize($img . $icon);
             $icons_ready[] = array("image" => $img . $icon, "size" => $sz);
         }
         //            $fileSystem->copy($img.$icon ,public_path().'/builds/ios/'.$label.'/'.$version.'/'.$bundle.$sz[0].'x'.$sz[1].'.png');
     }
     $label_model = Label::where('label_name', '=', $label)->where('build_type_id', '=', self::BUILD_IOS_TYPE_ID)->first();
     if ($label_model != null) {
         $version_model = $label_model->versions()->where('version', '=', $version)->first();
         if ($version_model != null) {
             $build_version_count = Build::where('version_id', '=', $version_model->id)->count();
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => $build_version_count + 1));
         } else {
             $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
         }
     } else {
         $label_model = Label::create(array('label_name' => $label, 'build_type_id' => self::BUILD_IOS_TYPE_ID));
         $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
         $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
     }
     $fn = public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.ipa';
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build);
     }
     $fileSystem->move($ipa->getRealPath(), $fn);
     $max_size = 0;
     foreach ($icons_ready as $icon) {
         if ($icon["size"][0] > $max_size) {
             $max_size = $icon["size"][0];
         }
     }
     foreach ($icons_ready as $icon) {
         if ($icon["size"][0] == $max_size) {
             $fileSystem->copy($icon["image"], public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
         }
     }
     if (empty($icons_ready)) {
         $fileSystem->copy($default_icon, public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
     }
     $fileSystem->deleteDirectory('/tmp/bundle/tmp');
     echo Config::get("app.domain") . "/ios/builds/{$label}/{$version}/{$build->build}\n";
     return "";
 }
示例#24
0
 /**
  * Parse an individual .gcov file.
  **/
 public function ParseGcovFile($fileinfo)
 {
     $coverageFileLog = new CoverageFileLog();
     $coverageFileLog->AggregateBuildId = $this->AggregateBuildId;
     $coverageFileLog->PreviousAggregateParentId = $this->PreviousAggregateParentId;
     $coverageFile = new CoverageFile();
     $coverage = new Coverage();
     $coverage->CoverageFile = $coverageFile;
     // Begin parsing this file.
     // The first thing we look for is the full path to this source file.
     $file = new SplFileObject($fileinfo);
     $path = '';
     while (!$file->eof()) {
         $gcovLine = $file->current();
         $term = ':Source:';
         $pos = strpos($gcovLine, $term);
         if ($pos !== false) {
             $path = substr($gcovLine, $pos + strlen($term));
             break;
         }
         $file->next();
     }
     if (empty($path)) {
         return;
     }
     // Check if this file belongs to a different SubProject.
     $buildid = $this->Build->Id;
     if (!empty($this->SubProjectPath) && strpos($path, $this->SubProjectPath) === false) {
         // Find the SubProject that corresponds to this path.
         $query = "SELECT id, name, path FROM subproject\n                WHERE projectid = {$this->ProjectId} AND\n                endtime = '1980-01-01 00:00:00' AND\n                path != '' AND\n                '{$path}' LIKE CONCAT('%',path,'%')";
         $result = pdo_query($query);
         if (!$result || pdo_num_rows($result) == 0) {
             add_log("No SubProject found for '{$path}'", 'ParseGcovFile', LOG_INFO, $this->ProjectId, $this->Build->Id);
             return;
         }
         $row = pdo_fetch_array($result);
         $subprojectid = $row['id'];
         $subprojectname = $row['name'];
         $subprojectpath = $row['path'];
         // Find the sibling build that performed this SubProject.
         $siblingBuild = new Build();
         $query = 'SELECT b.id FROM build AS b
             INNER JOIN subproject2build AS sp2b ON (sp2b.buildid=b.id)
             WHERE b.parentid=
             (SELECT parentid FROM build WHERE id=' . $this->Build->Id . ")\n                AND sp2b.subprojectid={$subprojectid}";
         $row = pdo_single_row_query($query);
         if ($row && array_key_exists('id', $row)) {
             $buildid = $row['id'];
             $siblingBuild->Id = $buildid;
             $siblingBuild->FillFromId($buildid);
         } else {
             // Build doesn't exist yet, add it here.
             $siblingBuild->Name = $this->Build->Name;
             $siblingBuild->ProjectId = $this->ProjectId;
             $siblingBuild->SiteId = $this->Build->SiteId;
             $siblingBuild->SetParentId($this->Build->GetParentId());
             $siblingBuild->SetStamp($this->Build->GetStamp());
             $siblingBuild->SetSubProject($subprojectname);
             $siblingBuild->StartTime = $this->Build->StartTime;
             $siblingBuild->EndTime = $this->Build->EndTime;
             $siblingBuild->SubmitTime = gmdate(FMT_DATETIME);
             add_build($siblingBuild, 0);
             $buildid = $siblingBuild->Id;
         }
         $coverageFileLog->Build = $siblingBuild;
         // Remove any part of the file path that comes before
         // the subproject path.
         $path = substr($path, strpos($path, $subprojectpath));
         // Replace the subproject path with '.'
         $path = substr_replace($path, '.', 0, strlen($subprojectpath));
     } else {
         // If this source file isn't from the source or binary directory
         // we shouldn't include it in our coverage report.
         if (!empty($this->SubProjectPath) && strpos($path, $this->SubProjectPath) !== false) {
             $path = substr($path, strpos($path, $this->SubProjectPath));
             $path = substr_replace($path, '.', 0, strlen($this->SubProjectPath));
         } elseif (strpos($path, $this->SourceDirectory) !== false) {
             $path = str_replace($this->SourceDirectory, '.', trim($path));
         } elseif (strpos($path, $this->BinaryDirectory) !== false) {
             $path = str_replace($this->BinaryDirectory, '.', trim($path));
         } else {
             return;
         }
         $coverageFileLog->Build = $this->Build;
     }
     // Get a reference to the coverage summary for this build.
     if ($buildid === $this->Build->Id) {
         $coverageSummary = $this->CoverageSummary;
     } else {
         if (!array_key_exists($buildid, $this->SubProjectSummaries)) {
             $coverageSummary = new CoverageSummary();
             $coverageSummary->BuildId = $buildid;
             $this->SubProjectSummaries[$buildid] = $coverageSummary;
         } else {
             $coverageSummary = $this->SubProjectSummaries[$buildid];
         }
     }
     // Use a regexp to resolve any /../ in this path.
     // We can't use realpath() because we're referencing a path that
     // doesn't exist on the server.
     // For a source file that contains:
     //   #include "src/../include/foo.h"
     // CDash will report the covered file as include/foo.h
     $pattern = "#/[^/]*?/\\.\\./#";
     while (strpos($path, "/../") !== false) {
         $path = preg_replace($pattern, "/", $path, 1);
     }
     $coverageFile->FullPath = trim($path);
     $lineNumber = 0;
     // The lack of rewind is intentional.
     while (!$file->eof()) {
         $gcovLine = $file->current();
         // "Ordinary" entries in a .gcov file take the following format:
         // <lineNumber>: <timesHit>: <source code at that line>
         // So we check if this line matches the format & parse the
         // data out of it if so.
         $fields = explode(':', $gcovLine, 3);
         if (count($fields) > 2) {
             // Separate out delimited values from this line.
             $timesHit = trim($fields[0]);
             $lineNumber = trim($fields[1]);
             $sourceLine = rtrim($fields[2]);
             if ($lineNumber > 0) {
                 $coverageFile->File .= $sourceLine;
                 // cannot be <br/> for backward compatibility.
                 $coverageFile->File .= '<br>';
             }
             // This is how gcov indicates a line of unexecutable code.
             if ($timesHit === '-') {
                 $file->next();
                 continue;
             }
             // This is how gcov indicates an uncovered line.
             if ($timesHit === '#####') {
                 $timesHit = 0;
             }
             $coverageFileLog->AddLine($lineNumber - 1, $timesHit);
             $file->next();
         } else {
             $coveredBranches = 0;
             $uncoveredBranches = 0;
             $throwBranches = 0;
             $fallthroughBranches = 0;
             while (count($fields) < 3 && !$file->eof()) {
                 // Parse branch coverage here.
                 if (substr($gcovLine, 0, 6) === 'branch') {
                     // Figure out whether this branch was covered or not.
                     if (strpos($gcovLine, 'taken 0%') !== false) {
                         $uncoveredBranches += 1;
                     } else {
                         $coveredBranches += 1;
                     }
                     // Also keep track of the different types of branches encountered.
                     if (strpos($gcovLine, '(throw)') !== false) {
                         $throwBranches += 1;
                     } elseif (strpos($gcovLine, '(fallthrough)') !== false) {
                         $fallthroughBranches += 1;
                     }
                 }
                 $file->next();
                 $gcovLine = $file->current();
                 $fields = explode(':', $gcovLine);
             }
             // Don't report branch coverage for this line if we only
             // encountered (throw) and (fallthrough) branches here.
             $totalBranches = $coveredBranches + $uncoveredBranches;
             if ($totalBranches > 0 && $totalBranches > $throwBranches + $fallthroughBranches) {
                 $coverageFileLog->AddBranch($lineNumber - 1, $coveredBranches, $totalBranches);
             }
         }
     }
     // Save these models to the database.
     $coverageFile->TrimLastNewline();
     $coverageFile->Update($buildid);
     $coverageFileLog->BuildId = $buildid;
     $coverageFileLog->FileId = $coverageFile->Id;
     $coverageFileLog->Insert(true);
     // Query the filelog to get how many lines & branches were covered.
     // We do this after inserting the filelog because we want to accurately
     // reflect the union of the current and previously existing results
     // (if any).
     $stats = $coverageFileLog->GetStats();
     $coverage->LocUntested = $stats['locuntested'];
     $coverage->LocTested = $stats['loctested'];
     $coverage->Covered = 1;
     $coverage->BranchesUntested = $stats['branchesuntested'];
     $coverage->BranchesTested = $stats['branchestested'];
     // Add any labels.
     if (array_key_exists($path, $this->Labels)) {
         foreach ($this->Labels[$path] as $labelText) {
             $label = new Label();
             $label->SetText($labelText);
             $coverage->AddLabel($label);
         }
     }
     // Add this Coverage to our summary.
     $coverageSummary->AddCoverage($coverage);
 }
示例#25
0
 public function testGithubPRComment()
 {
     echo "1. testGithubPRComment\n";
     global $configure;
     $this->login();
     // Create a project named CDash and set its repository information.
     $settings = ['Name' => 'CDash', 'Description' => 'CDash', 'CvsUrl' => 'github.com/Kitware/CDash', 'CvsViewerType' => 'github', 'BugTrackerFileUrl' => 'http://public.kitware.com/Bug/view.php?id=', 'repositories' => [['url' => 'https://github.com/Kitware/CDash', 'branch' => 'master', 'username' => $configure['github_username'], 'password' => $configure['github_password']]]];
     $this->ProjectId = $this->createProject($settings);
     if ($this->ProjectId < 1) {
         return 1;
     }
     // Setup subprojects by submitting the Project.xml file.
     global $configure;
     // Submit the file.
     $url = $this->url . '/submit.php?project=CDash';
     $result = $this->uploadfile($url, dirname(__FILE__) . '/data/GithubPR/Project.xml');
     $this->deleteLog($this->logfilename);
     // Submit a failing test.
     echo "Submitting Test.xml\n";
     if (!$this->submitPullRequestFile(dirname(__FILE__) . '/data/GithubPR/Test.xml')) {
         return 1;
     }
     // Submit a broken build.
     echo "Submitting Build.xml\n";
     if (!$this->submitPullRequestFile(dirname(__FILE__) . '/data/GithubPR/Build.xml')) {
         return 1;
     }
     // Submit a failed configure.
     echo "Submitting Configure.xml\n";
     if (!$this->submitPullRequestFile(dirname(__FILE__) . '/data/GithubPR/Configure.xml')) {
         return 1;
     }
     // Make sure these builds link back to the GitHub PR.
     $row = pdo_single_row_query("SELECT id, parentid FROM build\n                WHERE name = 'test_PR_comment' AND parentid>0 LIMIT 1");
     $build = new Build();
     $build->Id = $row['id'];
     $build->FillFromId($build->Id);
     $date = $build->GetDate();
     // Parent view
     $content = $this->connect($this->url . "/api/v1/index.php?project=CDash&date={$date}");
     $jsonobj = json_decode($content, true);
     $buildgroup = array_pop($jsonobj['buildgroups']);
     $build_response = $buildgroup['builds'][0];
     if ($build_response['changelink'] !== 'github.com/Kitware/CDash/pull/80') {
         $this->fail("Expected changelink not found for parent build.  Found: " . $build_response['changelink']);
     }
     if ($build_response['changeicon'] !== 'img/Octocat.png') {
         $this->fail("Expected changeicon not found for parent build.  Found: " . $build_response['changeicon']);
     }
     // Child view
     $parentid = $row['parentid'];
     $content = $this->connect($this->url . "/api/v1/index.php?project=CDash&parentid={$parentid}");
     $jsonobj = json_decode($content, true);
     if ($jsonobj['changelink'] !== 'github.com/Kitware/CDash/pull/80') {
         $this->fail("Expected changelink not found for parent build");
     }
     if ($jsonobj['changeicon'] !== 'img/Octocat.png') {
         $this->fail("Expected changeicon not found for parent build");
     }
     // Delete the project now that we're done with it.
     $this->deleteProject($this->ProjectId);
 }
示例#26
0
/** Main function to send email if necessary */
function sendemail($handler, $projectid)
{
    include 'config/config.php';
    include_once 'include/common.php';
    require_once 'include/pdo.php';
    require_once 'models/build.php';
    require_once 'models/project.php';
    require_once 'models/buildgroup.php';
    $Project = new Project();
    $Project->Id = $projectid;
    $Project->Fill();
    $sendEmail = null;
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
        include_once 'local/sendemail.php';
        $sendEmail = new SendEmail();
        $sendEmail->SetProjectId($projectid);
    }
    // If we shouldn't sent any emails we stop
    if ($Project->EmailBrokenSubmission == 0) {
        return;
    }
    // If the handler has a buildid (it should), we use it
    if (isset($handler->BuildId) && $handler->BuildId > 0) {
        $buildid = $handler->BuildId;
    } else {
        // Get the build id
        $name = $handler->getBuildName();
        $stamp = $handler->getBuildStamp();
        $sitename = $handler->getSiteName();
        $buildid = get_build_id($name, $stamp, $projectid, $sitename);
    }
    if ($buildid < 0) {
        return;
    }
    //add_log("Buildid ".$buildid,"sendemail ".$Project->Name,LOG_INFO);
    //  Check if the group as no email
    $Build = new Build();
    $Build->Id = $buildid;
    $groupid = $Build->GetGroup();
    $BuildGroup = new BuildGroup();
    $BuildGroup->SetId($groupid);
    // If we specified no email we stop here
    if ($BuildGroup->GetSummaryEmail() == 2) {
        return;
    }
    $emailCommitters = $BuildGroup->GetEmailCommitters();
    $errors = check_email_errors($buildid, $Project->EmailTestTimingChanged, $Project->TestTimeMaxStatus, !$Project->EmailRedundantFailures);
    // We have some fixes
    if ($errors['hasfixes']) {
        $Build->FillFromId($Build->Id);
        // Get the list of person who should get the email
        $lookup_result = lookup_emails_to_send($errors, $buildid, $projectid, $Build->Type, true, $emailCommitters);
        $userids = $lookup_result['userids'];
        foreach ($userids as $userid) {
            $emailtext = array();
            $emailtext['nfixes'] = 0;
            // Check if an email has been sent already for this user
            foreach ($errors['fixes'] as $fixkey => $nfixes) {
                if ($nfixes == 0) {
                    continue;
                }
                if (!check_email_sent($userid, $buildid, $fixkey)) {
                    $emailtext['category'][$fixkey] = $nfixes;
                    $emailtext['nfixes'] = 1;
                }
            }
            // Send the email
            if ($emailtext['nfixes'] == 1) {
                send_email_fix_to_user($userid, $emailtext, $Build, $Project);
            }
        }
    }
    // No error we return
    if (!$errors['errors']) {
        return;
    }
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
        $sendEmail->BuildId = $Build->Id;
        $sendEmail->Errors = $errors;
    }
    // If we should send a summary email
    if ($BuildGroup->GetSummaryEmail() == 1) {
        // Send the summary email
        sendsummaryemail($projectid, $groupid, $errors, $buildid);
        if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
            $sendEmail->SendSummary();
        }
        return;
    }
    $Build->FillFromId($Build->Id);
    // Send build error
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
        $sendEmail->SendBuildError();
    }
    // Lookup the list of people who should get the email, both registered
    // users *and* committers:
    //
    $lookup_result = lookup_emails_to_send($errors, $buildid, $projectid, $Build->Type, false, $emailCommitters);
    // Loop through the *registered* users:
    //
    $userids = $lookup_result['userids'];
    foreach ($userids as $userid) {
        send_error_email($userid, '', $sendEmail, $errors, $Build, $Project);
    }
    // Loop through "other" users, if necessary:
    //
    // ...people who committed code, but are *not* registered CDash users, but
    // only if the 'emailcommitters' field is on for this build group.
    //
    if ($emailCommitters) {
        $committeremails = $lookup_result['committeremails'];
        foreach ($committeremails as $committeremail) {
            send_error_email(0, $committeremail, $sendEmail, $errors, $Build, $Project, getHandlerErrorKeyPrefix($handler));
        }
    }
}
示例#27
0
文件: index.php 项目: kitware/cdash
function echo_main_dashboard_JSON($project_instance, $date)
{
    $start = microtime_float();
    $noforcelogin = 1;
    include_once dirname(dirname(dirname(__DIR__))) . '/config/config.php';
    require_once 'include/pdo.php';
    include 'public/login.php';
    include_once 'models/banner.php';
    include_once 'models/build.php';
    include_once 'models/subproject.php';
    $response = array();
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    if (!$db) {
        $response['error'] = 'Error connecting to CDash database server';
        echo json_encode($response);
        return;
    }
    if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) {
        $response['error'] = 'Error selecting CDash database';
        echo json_encode($response);
        return;
    }
    $projectid = $project_instance->Id;
    $project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'");
    if (pdo_num_rows($project) > 0) {
        $project_array = pdo_fetch_array($project);
        $projectname = $project_array['name'];
        if (isset($project_array['testingdataurl']) && $project_array['testingdataurl'] != '') {
            $testingdataurl = make_cdash_url(htmlentities($project_array['testingdataurl']));
        }
    } else {
        $response['error'] = "This project doesn't exist. Maybe the URL you are trying to access is wrong.";
        echo json_encode($response);
        return;
    }
    if (!checkUserPolicy(@$_SESSION['cdash']['loginid'], $project_array['id'], 1)) {
        $response['requirelogin'] = 1;
        echo json_encode($response);
        return;
    }
    $response = begin_JSON_response();
    $response['title'] = "CDash - {$projectname}";
    $response['feed'] = $CDASH_ENABLE_FEED;
    $response['showcalendar'] = 1;
    $Banner = new Banner();
    $Banner->SetProjectId(0);
    $text = $Banner->GetText();
    $banners = array();
    if ($text !== false) {
        $banners[] = $text;
    }
    $Banner->SetProjectId($projectid);
    $text = $Banner->GetText();
    if ($text !== false) {
        $banners[] = $text;
    }
    $response['banners'] = $banners;
    $site_response = array();
    // If parentid is set we need to lookup the date for this build
    // because it is not specified as a query string parameter.
    if (isset($_GET['parentid'])) {
        $parentid = pdo_real_escape_numeric($_GET['parentid']);
        $parent_build = new Build();
        $parent_build->Id = $parentid;
        $date = $parent_build->GetDate();
        $response['parentid'] = $parentid;
    } else {
        $response['parentid'] = -1;
    }
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array['nightlytime']);
    // Main dashboard section
    get_dashboard_JSON($projectname, $date, $response);
    $response['displaylabels'] = $project_array['displaylabels'];
    $page_id = 'index.php';
    $response['childview'] = 0;
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/models/proProject.php')) {
        include_once 'local/models/proProject.php';
        $pro = new proProject();
        $pro->ProjectId = $projectid;
        $response['proedition'] = $pro->GetEdition(1);
    }
    if ($currentstarttime > time() && !isset($_GET['parentid'])) {
        $response['error'] = 'CDash cannot predict the future (yet)';
        echo json_encode($response);
        return;
    }
    // Menu definition
    $response['menu'] = array();
    $beginning_timestamp = $currentstarttime;
    $end_timestamp = $currentstarttime + 3600 * 24;
    $beginning_UTCDate = gmdate(FMT_DATETIME, $beginning_timestamp);
    $end_UTCDate = gmdate(FMT_DATETIME, $end_timestamp);
    if ($project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) {
        $response['menu']['subprojects'] = 1;
    }
    if (isset($_GET['parentid'])) {
        $page_id = 'indexchildren.php';
        $response['childview'] = 1;
        // When a parentid is specified, we should link to the next build,
        // not the next day.
        $previous_buildid = $parent_build->GetPreviousBuildId();
        $current_buildid = $parent_build->GetCurrentBuildId();
        $next_buildid = $parent_build->GetNextBuildId();
        $base_url = 'index.php?project=' . urlencode($projectname);
        if ($previous_buildid > 0) {
            $response['menu']['previous'] = "{$base_url}&parentid={$previous_buildid}";
        } else {
            $response['menu']['noprevious'] = '1';
        }
        $response['menu']['current'] = "{$base_url}&parentid={$current_buildid}";
        if ($next_buildid > 0) {
            $response['menu']['next'] = "{$base_url}&parentid={$next_buildid}";
        } else {
            $response['menu']['nonext'] = '1';
        }
    } elseif (!has_next_date($date, $currentstarttime)) {
        $response['menu']['nonext'] = 1;
    }
    // Check if a SubProject parameter was specified.
    $subproject_name = @$_GET['subproject'];
    $subprojectid = false;
    if ($subproject_name) {
        $SubProject = new SubProject();
        $subproject_name = htmlspecialchars(pdo_real_escape_string($subproject_name));
        $SubProject->SetName($subproject_name);
        $SubProject->SetProjectId($projectid);
        $subprojectid = $SubProject->GetId();
        if ($subprojectid) {
            // Add an extra URL argument for the menu
            $response['extraurl'] = '&subproject=' . urlencode($subproject_name);
            $response['subprojectname'] = $subproject_name;
            $subproject_response = array();
            $subproject_response['name'] = $SubProject->GetName();
            $dependencies = $SubProject->GetDependencies();
            if ($dependencies) {
                $dependencies_response = array();
                foreach ($dependencies as $dependency) {
                    $dependency_response = array();
                    $DependProject = new SubProject();
                    $DependProject->SetId($dependency);
                    $dependency_response['name'] = $DependProject->GetName();
                    $dependency_response['name_encoded'] = urlencode($DependProject->GetName());
                    $dependency_response['nbuilderror'] = $DependProject->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nbuildwarning'] = $DependProject->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nbuildpass'] = $DependProject->GetNumberOfPassingBuilds($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nconfigureerror'] = $DependProject->GetNumberOfErrorConfigures($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nconfigurewarning'] = $DependProject->GetNumberOfWarningConfigures($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nconfigurepass'] = $DependProject->GetNumberOfPassingConfigures($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['ntestpass'] = $DependProject->GetNumberOfPassingTests($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['ntestfail'] = $DependProject->GetNumberOfFailingTests($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['ntestnotrun'] = $DependProject->GetNumberOfNotRunTests($beginning_UTCDate, $end_UTCDate);
                    if (strlen($DependProject->GetLastSubmission()) == 0) {
                        $dependency_response['lastsubmission'] = 'NA';
                    } else {
                        $dependency_response['lastsubmission'] = $DependProject->GetLastSubmission();
                    }
                    $dependencies_response[] = $dependency_response;
                }
                $subproject_response['dependencies'] = $dependencies_response;
            }
            $response['subproject'] = $subproject_response;
        } else {
            add_log("SubProject '{$subproject_name}' does not exist", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING);
        }
    }
    if (isset($testingdataurl)) {
        $response['testingdataurl'] = $testingdataurl;
    }
    // updates
    $updates_response = array();
    $gmdate = gmdate(FMT_DATE, $currentstarttime);
    $updates_response['url'] = 'viewChanges.php?project=' . urlencode($projectname) . '&amp;date=' . $gmdate;
    $dailyupdate = pdo_query("SELECT count(ds.dailyupdateid),count(distinct ds.author)\n            FROM dailyupdate AS d LEFT JOIN dailyupdatefile AS ds ON (ds.dailyupdateid = d.id)\n            WHERE d.date='{$gmdate}' and d.projectid='{$projectid}' GROUP BY ds.dailyupdateid");
    if (pdo_num_rows($dailyupdate) > 0) {
        $dailupdate_array = pdo_fetch_array($dailyupdate);
        $updates_response['nchanges'] = $dailupdate_array[0];
        $updates_response['nauthors'] = $dailupdate_array[1];
    } else {
        $updates_response['nchanges'] = -1;
    }
    $updates_response['timestamp'] = date('l, F d Y - H:i T', $currentstarttime);
    $response['updates'] = $updates_response;
    // This array is used to track if expected builds are found or not.
    $received_builds = array();
    // Get info about our buildgroups.
    $buildgroups_response = array();
    $buildgroup_result = pdo_query("SELECT bg.id, bg.name, bgp.position FROM buildgroup AS bg\n            LEFT JOIN buildgroupposition AS bgp ON (bgp.buildgroupid=bg.id)\n            WHERE bg.projectid={$projectid} AND bg.starttime < '{$beginning_UTCDate}' AND\n            (bg.endtime > '{$beginning_UTCDate}' OR\n             bg.endtime='1980-01-01 00:00:00')");
    while ($buildgroup_array = pdo_fetch_array($buildgroup_result)) {
        $buildgroup_response = array();
        $groupname = $buildgroup_array['name'];
        $buildgroup_response['id'] = $buildgroup_array['id'];
        $buildgroup_response['name'] = $groupname;
        $buildgroup_response['linkname'] = str_replace(' ', '_', $groupname);
        $buildgroup_response['position'] = $buildgroup_array['position'];
        $buildgroup_response['numupdatedfiles'] = 0;
        $buildgroup_response['numupdateerror'] = 0;
        $buildgroup_response['numupdatewarning'] = 0;
        $buildgroup_response['updateduration'] = 0;
        $buildgroup_response['configureduration'] = 0;
        $buildgroup_response['numconfigureerror'] = 0;
        $buildgroup_response['numconfigurewarning'] = 0;
        $buildgroup_response['numbuilderror'] = 0;
        $buildgroup_response['numbuildwarning'] = 0;
        $buildgroup_response['numtestnotrun'] = 0;
        $buildgroup_response['numtestfail'] = 0;
        $buildgroup_response['numtestpass'] = 0;
        $buildgroup_response['testduration'] = 0;
        $buildgroup_response['hasupdatedata'] = false;
        $buildgroup_response['hasconfiguredata'] = false;
        $buildgroup_response['hascompilationdata'] = false;
        $buildgroup_response['hastestdata'] = false;
        $buildgroup_response['hasnormalbuilds'] = false;
        $buildgroup_response['hasparentbuilds'] = false;
        $buildgroup_response['builds'] = array();
        $received_builds[$groupname] = array();
        $buildgroups_response[] = $buildgroup_response;
    }
    // Filters:
    //
    $filterdata = get_filterdata_from_request($page_id);
    $filter_sql = $filterdata['sql'];
    $limit_sql = '';
    if ($filterdata['limit'] > 0) {
        $limit_sql = ' LIMIT ' . $filterdata['limit'];
    }
    unset($filterdata['xml']);
    $response['filterdata'] = $filterdata;
    $response['filterurl'] = get_filterurl();
    // Check if we should be excluding some SubProjects from our
    // build results.
    $include_subprojects = false;
    $exclude_subprojects = false;
    $included_subprojects = array();
    $excluded_subprojects = array();
    $selected_subprojects = '';
    $num_selected_subprojects = 0;
    $filter_on_labels = false;
    $share_label_filters = false;
    foreach ($filterdata['filters'] as $filter) {
        if ($filter['field'] == 'subprojects') {
            if ($filter['compare'] == 92) {
                $excluded_subprojects[] = $filter['value'];
            } elseif ($filter['compare'] == 93) {
                $included_subprojects[] = $filter['value'];
            }
        } elseif ($filter['field'] == 'label') {
            $filter_on_labels = true;
        }
    }
    if ($filter_on_labels && $project_instance->ShareLabelFilters) {
        $share_label_filters = true;
        $response['sharelabelfilters'] = true;
        $label_ids_array = get_label_ids_from_filterdata($filterdata);
        $label_ids = '(' . implode(', ', $label_ids_array) . ')';
    }
    // Include takes precedence over exclude.
    if (!empty($included_subprojects)) {
        $num_selected_subprojects = count($included_subprojects);
        $selected_subprojects = implode("','", $included_subprojects);
        $selected_subprojects = "('" . $selected_subprojects . "')";
        $include_subprojects = true;
    } elseif (!empty($excluded_subprojects)) {
        $num_selected_subprojects = count($excluded_subprojects);
        $selected_subprojects = implode("','", $excluded_subprojects);
        $selected_subprojects = "('" . $selected_subprojects . "')";
        $exclude_subprojects = true;
    }
    // add a request for the subproject
    $subprojectsql = '';
    if ($subproject_name && is_numeric($subprojectid)) {
        $subprojectsql = ' AND sp2b.subprojectid=' . $subprojectid;
    }
    // Use this as the default date clause, but if $filterdata has a date clause,
    // then cancel this one out:
    //
    $date_clause = "AND b.starttime<'{$end_UTCDate}' AND b.starttime>='{$beginning_UTCDate}' ";
    if ($filterdata['hasdateclause']) {
        $date_clause = '';
    }
    $parent_clause = '';
    if (isset($_GET['parentid'])) {
        // If we have a parentid, then we should only show children of that build.
        // Date becomes irrelevant in this case.
        $parent_clause = 'AND (b.parentid = ' . qnum($_GET['parentid']) . ') ';
        $date_clause = '';
    } elseif (empty($subprojectsql)) {
        // Only show builds that are not children.
        $parent_clause = 'AND (b.parentid = -1 OR b.parentid = 0) ';
    }
    $build_rows = array();
    // If the user is logged in we display if the build has some changes for him
    $userupdatesql = '';
    if (isset($_SESSION['cdash']) && array_key_exists('loginid', $_SESSION['cdash'])) {
        $userupdatesql = "(SELECT count(updatefile.updateid) FROM updatefile,build2update,user2project,\n            user2repository\n                WHERE build2update.buildid=b.id\n                AND build2update.updateid=updatefile.updateid\n                AND user2project.projectid=b.projectid\n                AND user2project.userid='" . $_SESSION['cdash']['loginid'] . "'\n                AND user2repository.userid=user2project.userid\n                AND (user2repository.projectid=0 OR user2repository.projectid=b.projectid)\n                AND user2repository.credential=updatefile.author) AS userupdates,";
    }
    $sql = get_index_query();
    $sql .= "WHERE b.projectid='{$projectid}' AND g.type='Daily'\n        {$parent_clause} {$date_clause} {$subprojectsql} {$filter_sql} {$limit_sql}";
    // We shouldn't get any builds for group that have been deleted (otherwise something is wrong)
    $builds = pdo_query($sql);
    // Log any errors
    $pdo_error = pdo_error();
    if (strlen($pdo_error) > 0) {
        add_log('SQL error: ' . $pdo_error, 'Index.php', LOG_ERR);
    }
    // Gather up results from this query.
    $build_data = array();
    while ($build_row = pdo_fetch_array($builds)) {
        $build_data[] = $build_row;
    }
    $dynamic_builds = array();
    if (empty($filter_sql)) {
        $dynamic_builds = get_dynamic_builds($projectid, $end_UTCDate);
        $build_data = array_merge($build_data, $dynamic_builds);
    }
    // Check if we need to summarize coverage by subproject groups.
    // This happens when we have subprojects and we're looking at the children
    // of a specific build.
    $coverage_groups = array();
    if (isset($_GET['parentid']) && $_GET['parentid'] > 0 && $project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) {
        $groups = $project_instance->GetSubProjectGroups();
        foreach ($groups as $group) {
            // Keep track of coverage info on a per-group basis.
            $groupId = $group->GetId();
            $coverage_groups[$groupId] = array();
            $coverageThreshold = $group->GetCoverageThreshold();
            $coverage_groups[$groupId]['thresholdgreen'] = $coverageThreshold;
            $coverage_groups[$groupId]['thresholdyellow'] = $coverageThreshold * 0.7;
            $coverage_groups[$groupId]['label'] = $group->GetName();
            $coverage_groups[$groupId]['loctested'] = 0;
            $coverage_groups[$groupId]['locuntested'] = 0;
            $coverage_groups[$groupId]['position'] = $group->GetPosition();
            $coverage_groups[$groupId]['coverages'] = array();
        }
        if (count($groups) > 1) {
            // Add a Total group too.
            $coverage_groups[0] = array();
            $coverageThreshold = $project_array['coveragethreshold'];
            $coverage_groups[0]['thresholdgreen'] = $coverageThreshold;
            $coverage_groups[0]['thresholdyellow'] = $coverageThreshold * 0.7;
            $coverage_groups[0]['label'] = 'Total';
            $coverage_groups[0]['loctested'] = 0;
            $coverage_groups[0]['locuntested'] = 0;
            $coverage_groups[0]['position'] = 0;
        }
    }
    // Fetch all the rows of builds into a php array.
    // Compute additional fields for each row that we'll need to generate the xml.
    //
    $build_rows = array();
    foreach ($build_data as $build_row) {
        // Fields that come from the initial query:
        //  id
        //  sitename
        //  stamp
        //  name
        //  siteid
        //  type
        //  generator
        //  starttime
        //  endtime
        //  submittime
        //  groupname
        //  position
        //  groupid
        //  countupdatefiles
        //  updatestatus
        //  countupdatewarnings
        //  countbuildwarnings
        //  countbuilderrors
        //  countbuilderrordiff
        //  countbuildwarningdiff
        //  configureduration
        //  countconfigureerrors
        //  countconfigurewarnings
        //  countconfigurewarningdiff
        //  counttestsnotrun
        //  counttestsnotrundiff
        //  counttestsfailed
        //  counttestsfaileddiff
        //  counttestspassed
        //  counttestspasseddiff
        //  countteststimestatusfailed
        //  countteststimestatusfaileddiff
        //  testduration
        //
        // Fields that we add within this loop:
        //  maxstarttime
        //  buildids (array of buildids for summary rows)
        //  countbuildnotes (added by users)
        //  labels
        //  updateduration
        //  countupdateerrors
        //  test
        //
        $buildid = $build_row['id'];
        $groupid = $build_row['groupid'];
        $siteid = $build_row['siteid'];
        $parentid = $build_row['parentid'];
        $build_row['buildids'][] = $buildid;
        $build_row['maxstarttime'] = $build_row['starttime'];
        // Updates
        if (!empty($build_row['updatestarttime'])) {
            $build_row['updateduration'] = round((strtotime($build_row['updateendtime']) - strtotime($build_row['updatestarttime'])) / 60, 1);
        } else {
            $build_row['updateduration'] = 0;
        }
        if (strlen($build_row['updatestatus']) > 0 && $build_row['updatestatus'] != '0') {
            $build_row['countupdateerrors'] = 1;
        } else {
            $build_row['countupdateerrors'] = 0;
        }
        // Error/Warnings differences
        if (empty($build_row['countbuilderrordiffp'])) {
            $build_row['countbuilderrordiffp'] = 0;
        }
        if (empty($build_row['countbuilderrordiffn'])) {
            $build_row['countbuilderrordiffn'] = 0;
        }
        if (empty($build_row['countbuildwarningdiffp'])) {
            $build_row['countbuildwarningdiffp'] = 0;
        }
        if (empty($build_row['countbuildwarningdiffn'])) {
            $build_row['countbuildwarningdiffn'] = 0;
        }
        $build_row['hasconfigure'] = 0;
        if ($build_row['countconfigureerrors'] != -1 || $build_row['countconfigurewarnings'] != -1) {
            $build_row['hasconfigure'] = 1;
        }
        if ($build_row['countconfigureerrors'] < 0) {
            $build_row['countconfigureerrors'] = 0;
        }
        if ($build_row['countconfigurewarnings'] < 0) {
            $build_row['countconfigurewarnings'] = 0;
        }
        if (empty($build_row['countconfigurewarningdiff'])) {
            $build_row['countconfigurewarningdiff'] = 0;
        }
        $build_row['hastest'] = 0;
        if ($build_row['counttestsfailed'] != -1) {
            $build_row['hastest'] = 1;
        }
        if (empty($build_row['testduration'])) {
            $time_array = pdo_fetch_array(pdo_query("SELECT SUM(time) FROM build2test WHERE buildid='{$buildid}'"));
            $build_row['testduration'] = round($time_array[0], 1);
        } else {
            $build_row['testduration'] = round($build_row['testduration'], 1);
        }
        $build_rows[] = $build_row;
    }
    // Generate the JSON response from the rows of builds.
    $response['coverages'] = array();
    $response['dynamicanalyses'] = array();
    $num_nightly_coverages_builds = 0;
    $show_aggregate = false;
    $response['comparecoverage'] = 0;
    foreach ($build_rows as $build_array) {
        $groupid = $build_array['groupid'];
        // Find the buildgroup array for this build.
        $i = -1;
        for ($j = 0; $j < count($buildgroups_response); $j++) {
            if ($buildgroups_response[$j]['id'] == $groupid) {
                $i = $j;
                break;
            }
        }
        if ($i == -1) {
            add_log("BuildGroup '{$groupid}' not found for build #" . $build_array['id'], __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING);
            continue;
        }
        $groupname = $buildgroups_response[$i]['name'];
        $build_response = array();
        $received_builds[$groupname][] = $build_array['sitename'] . '_' . $build_array['name'];
        $buildid = $build_array['id'];
        $siteid = $build_array['siteid'];
        $countChildrenResult = pdo_single_row_query('SELECT count(id) AS numchildren
                FROM build WHERE parentid=' . qnum($buildid));
        $numchildren = $countChildrenResult['numchildren'];
        $build_response['numchildren'] = $numchildren;
        $child_builds_hyperlink = '';
        $selected_configure_errors = 0;
        $selected_configure_warnings = 0;
        $selected_configure_duration = 0;
        $selected_build_errors = 0;
        $selected_build_warnings = 0;
        $selected_build_duration = 0;
        $selected_tests_not_run = 0;
        $selected_tests_failed = 0;
        $selected_tests_passed = 0;
        $selected_test_duration = 0;
        if ($numchildren > 0) {
            $child_builds_hyperlink = get_child_builds_hyperlink($build_array['id'], $filterdata);
            $build_response['multiplebuildshyperlink'] = $child_builds_hyperlink;
            $buildgroups_response[$i]['hasparentbuilds'] = true;
            // Compute selected (excluded or included) SubProject results.
            if ($selected_subprojects) {
                $select_query = "\n                    SELECT configureerrors, configurewarnings, configureduration,\n                           builderrors, buildwarnings, buildduration,\n                           b.starttime, b.endtime, testnotrun, testfailed, testpassed,\n                           btt.time AS testduration, sb.name\n                    FROM build AS b\n                    INNER JOIN subproject2build AS sb2b ON (b.id = sb2b.buildid)\n                    INNER JOIN subproject AS sb ON (sb2b.subprojectid = sb.id)\n                    LEFT JOIN buildtesttime AS btt ON (b.id=btt.buildid)\n                    WHERE b.parentid={$buildid}\n                    AND sb.name IN {$selected_subprojects}";
                $select_results = pdo_query($select_query);
                while ($select_array = pdo_fetch_array($select_results)) {
                    $selected_configure_errors += max(0, $select_array['configureerrors']);
                    $selected_configure_warnings += max(0, $select_array['configurewarnings']);
                    $selected_configure_duration += max(0, $select_array['configureduration']);
                    $selected_build_errors += max(0, $select_array['builderrors']);
                    $selected_build_warnings += max(0, $select_array['buildwarnings']);
                    $selected_build_duration += max(0, $select_array['buildduration']);
                    $selected_tests_not_run += max(0, $select_array['testnotrun']);
                    $selected_tests_failed += max(0, $select_array['testfailed']);
                    $selected_tests_passed += max(0, $select_array['testpassed']);
                    $selected_test_duration += max(0, $select_array['testduration']);
                }
            }
        } else {
            $buildgroups_response[$i]['hasnormalbuilds'] = true;
        }
        if (strtolower($build_array['type']) == 'continuous') {
            $buildgroups_response[$i]['sorttype'] = 'time';
        }
        // Attempt to determine the platform based on the OSName and the buildname
        $buildplatform = '';
        if (strtolower(substr($build_array['osname'], 0, 7)) == 'windows') {
            $buildplatform = 'windows';
        } elseif (strtolower(substr($build_array['osname'], 0, 8)) == 'mac os x') {
            $buildplatform = 'mac';
        } elseif (strtolower(substr($build_array['osname'], 0, 5)) == 'linux' || strtolower(substr($build_array['osname'], 0, 3)) == 'aix') {
            $buildplatform = 'linux';
        } elseif (strtolower(substr($build_array['osname'], 0, 7)) == 'freebsd') {
            $buildplatform = 'freebsd';
        } elseif (strtolower(substr($build_array['osname'], 0, 3)) == 'gnu') {
            $buildplatform = 'gnu';
        }
        // Add link based on changeid if appropriate.
        $changelink = null;
        $changeicon = null;
        if ($build_array['changeid'] && $project_instance->CvsViewerType === 'github') {
            $changelink = $project_instance->CvsUrl . '/pull/' . $build_array['changeid'];
            $changeicon = 'img/Octocat.png';
        }
        if (isset($_GET['parentid'])) {
            if (empty($site_response)) {
                $site_response['site'] = $build_array['sitename'];
                $site_response['siteoutoforder'] = $build_array['siteoutoforder'];
                $site_response['siteid'] = $siteid;
                $site_response['buildname'] = $build_array['name'];
                $site_response['buildplatform'] = $buildplatform;
                $site_response['generator'] = $build_array['generator'];
                if (!is_null($changelink)) {
                    $site_response['changelink'] = $changelink;
                    $site_response['changeicon'] = $changeicon;
                }
            }
        } else {
            $build_response['site'] = $build_array['sitename'];
            $build_response['siteoutoforder'] = $build_array['siteoutoforder'];
            $build_response['siteid'] = $siteid;
            $build_response['buildname'] = $build_array['name'];
            $build_response['buildplatform'] = $buildplatform;
            if (!is_null($changelink)) {
                $build_response['changelink'] = $changelink;
                $build_response['changeicon'] = $changeicon;
            }
        }
        if (isset($build_array['userupdates'])) {
            $build_response['userupdates'] = $build_array['userupdates'];
        }
        $build_response['id'] = $build_array['id'];
        $build_response['done'] = $build_array['done'];
        $build_response['uploadfilecount'] = $build_array['builduploadfiles'];
        $build_response['buildnotes'] = $build_array['countbuildnotes'];
        $build_response['notes'] = $build_array['countnotes'];
        // Figure out how many labels to report for this build.
        if (!array_key_exists('numlabels', $build_array) || $build_array['numlabels'] == 0) {
            $num_labels = 0;
        } else {
            $num_labels = $build_array['numlabels'];
        }
        $label_query = 'SELECT l.text FROM label AS l
            INNER JOIN label2build AS l2b ON (l.id=l2b.labelid)
            INNER JOIN build AS b ON (l2b.buildid=b.id)
            WHERE b.id=' . qnum($buildid);
        $build_labels = array();
        if ($num_selected_subprojects > 0) {
            // Special handling for whitelisting/blacklisting SubProjects.
            if ($include_subprojects) {
                $num_labels = 0;
            }
            $labels_result = pdo_query($label_query);
            while ($label_row = pdo_fetch_array($labels_result)) {
                // Whitelist case
                if ($include_subprojects && in_array($label_row['text'], $included_subprojects)) {
                    $num_labels++;
                    $build_labels[] = $label_row['text'];
                }
                // Blacklist case
                if ($exclude_subprojects) {
                    if (in_array($label_row['text'], $excluded_subprojects)) {
                        $num_labels--;
                    } else {
                        $build_labels[] = $label_row['text'];
                    }
                }
            }
            if ($num_labels === 0) {
                // Skip this build entirely if none of its SubProjects
                // survived filtering.
                continue;
            }
        }
        // Assign a label to this build based on how many labels it has.
        if ($num_labels == 0) {
            $build_label = '(none)';
        } elseif ($num_labels == 1) {
            // Exactly one label for this build
            if (!empty($build_labels)) {
                // If we're whitelisting or blacklisting we've already figured
                // out what this label is.
                $build_label = $build_labels[0];
            } else {
                // Otherwise we look it up here.
                $label_result = pdo_single_row_query($label_query);
                $build_label = $label_result['text'];
            }
        } else {
            // More than one label, just report the number.
            $build_label = "({$num_labels} labels)";
        }
        $build_response['label'] = $build_label;
        // Calculate this build's total duration.
        $duration = strtotime($build_array['endtime']) - strtotime($build_array['starttime']);
        $build_response['time'] = time_difference($duration, true);
        $build_response['timefull'] = $duration;
        $update_response = array();
        $countupdatefiles = $build_array['countupdatefiles'];
        $update_response['files'] = $countupdatefiles;
        $buildgroups_response[$i]['numupdatedfiles'] += $countupdatefiles;
        $build_response['hasupdate'] = false;
        if (!empty($build_array['updatestarttime'])) {
            $build_response['hasupdate'] = true;
            if ($build_array['countupdateerrors'] > 0) {
                $update_response['errors'] = 1;
                $buildgroups_response[$i]['numupdateerror'] += 1;
            } else {
                $update_response['errors'] = 0;
                if ($build_array['countupdatewarnings'] > 0) {
                    $update_response['warning'] = 1;
                    $buildgroups_response[$i]['numupdatewarning'] += 1;
                }
            }
            $duration = $build_array['updateduration'];
            $update_response['time'] = time_difference($duration * 60.0, true);
            $update_response['timefull'] = $duration;
            $buildgroups_response[$i]['updateduration'] += $duration;
            $buildgroups_response[$i]['hasupdatedata'] = true;
            $build_response['update'] = $update_response;
        }
        $compilation_response = array();
        if ($build_array['countbuilderrors'] >= 0) {
            if ($include_subprojects) {
                $nerrors = $selected_build_errors;
                $nwarnings = $selected_build_warnings;
                $buildduration = $selected_build_duration;
            } else {
                $nerrors = $build_array['countbuilderrors'] - $selected_build_errors;
                $nwarnings = $build_array['countbuildwarnings'] - $selected_build_warnings;
                $buildduration = $build_array['buildduration'] - $selected_build_duration;
            }
            $compilation_response['error'] = $nerrors;
            $buildgroups_response[$i]['numbuilderror'] += $nerrors;
            $compilation_response['warning'] = $nwarnings;
            $buildgroups_response[$i]['numbuildwarning'] += $nwarnings;
            $compilation_response['time'] = time_difference($buildduration, true);
            $compilation_response['timefull'] = $buildduration;
            if (!$include_subprojects && !$exclude_subprojects) {
                // Don't show diff when filtering by SubProject.
                $compilation_response['nerrordiffp'] = $build_array['countbuilderrordiffp'];
                $compilation_response['nerrordiffn'] = $build_array['countbuilderrordiffn'];
                $compilation_response['nwarningdiffp'] = $build_array['countbuildwarningdiffp'];
                $compilation_response['nwarningdiffn'] = $build_array['countbuildwarningdiffn'];
            }
        }
        $build_response['hascompilation'] = false;
        if (!empty($compilation_response)) {
            $build_response['hascompilation'] = true;
            $build_response['compilation'] = $compilation_response;
            $buildgroups_response[$i]['hascompilationdata'] = true;
        }
        $build_response['hasconfigure'] = false;
        if ($build_array['hasconfigure'] != 0) {
            $build_response['hasconfigure'] = true;
            $configure_response = array();
            if ($include_subprojects) {
                $nconfigureerrors = $selected_configure_errors;
                $nconfigurewarnings = $selected_configure_warnings;
                $configureduration = $selected_configure_duration;
            } else {
                $nconfigureerrors = $build_array['countconfigureerrors'] - $selected_configure_errors;
                $nconfigurewarnings = $build_array['countconfigurewarnings'] - $selected_configure_warnings;
                $configureduration = $build_array['configureduration'] - $selected_configure_duration;
            }
            $configure_response['error'] = $nconfigureerrors;
            $buildgroups_response[$i]['numconfigureerror'] += $nconfigureerrors;
            $configure_response['warning'] = $nconfigurewarnings;
            $buildgroups_response[$i]['numconfigurewarning'] += $nconfigurewarnings;
            if (!$include_subprojects && !$exclude_subprojects) {
                $configure_response['warningdiff'] = $build_array['countconfigurewarningdiff'];
            }
            $configure_response['time'] = time_difference($configureduration, true);
            $configure_response['timefull'] = $configureduration;
            $build_response['configure'] = $configure_response;
            $buildgroups_response[$i]['hasconfiguredata'] = true;
            $buildgroups_response[$i]['configureduration'] += $configureduration;
        }
        $build_response['hastest'] = false;
        if ($build_array['hastest'] != 0) {
            $build_response['hastest'] = true;
            $buildgroups_response[$i]['hastestdata'] = true;
            $test_response = array();
            if ($include_subprojects) {
                $nnotrun = $selected_tests_not_run;
                $nfail = $selected_tests_failed;
                $npass = $selected_tests_passed;
                $testduration = $selected_test_duration;
            } else {
                $nnotrun = $build_array['counttestsnotrun'] - $selected_tests_not_run;
                $nfail = $build_array['counttestsfailed'] - $selected_tests_failed;
                $npass = $build_array['counttestspassed'] - $selected_tests_passed;
                $testduration = $build_array['testduration'] - $selected_test_duration;
            }
            if (!$include_subprojects && !$exclude_subprojects) {
                $test_response['nnotrundiffp'] = $build_array['counttestsnotrundiffp'];
                $test_response['nnotrundiffn'] = $build_array['counttestsnotrundiffn'];
                $test_response['nfaildiffp'] = $build_array['counttestsfaileddiffp'];
                $test_response['nfaildiffn'] = $build_array['counttestsfaileddiffn'];
                $test_response['npassdiffp'] = $build_array['counttestspasseddiffp'];
                $test_response['npassdiffn'] = $build_array['counttestspasseddiffn'];
            }
            if ($project_array['showtesttime'] == 1) {
                $test_response['timestatus'] = $build_array['countteststimestatusfailed'];
                $test_response['ntimediffp'] = $build_array['countteststimestatusfaileddiffp'];
                $test_response['ntimediffn'] = $build_array['countteststimestatusfaileddiffn'];
            }
            if ($share_label_filters) {
                $label_query_base = "SELECT b2t.status, b2t.newstatus\n                    FROM build2test AS b2t\n                    INNER JOIN label2test AS l2t ON\n                    (l2t.testid=b2t.testid AND l2t.buildid=b2t.buildid)\n                    WHERE b2t.buildid = '{$buildid}' AND\n                    l2t.labelid IN {$label_ids}";
                $label_filter_query = $label_query_base . $limit_sql;
                $labels_result = pdo_query($label_filter_query);
                $nnotrun = 0;
                $nfail = 0;
                $npass = 0;
                $test_response['nfaildiffp'] = 0;
                $test_response['nfaildiffn'] = 0;
                $test_response['npassdiffp'] = 0;
                $test_response['npassdiffn'] = 0;
                $test_response['nnotrundiffp'] = 0;
                $test_response['nnotrundiffn'] = 0;
                while ($label_row = pdo_fetch_array($labels_result)) {
                    switch ($label_row['status']) {
                        case 'passed':
                            $npass++;
                            if ($label_row['newstatus'] == 1) {
                                $test_response['npassdiffp']++;
                            }
                            break;
                        case 'failed':
                            $nfail++;
                            if ($label_row['newstatus'] == 1) {
                                $test_response['nfaildiffp']++;
                            }
                            break;
                        case 'notrun':
                            $nnotrun++;
                            if ($label_row['newstatus'] == 1) {
                                $test_response['nnotrundiffp']++;
                            }
                            break;
                    }
                }
            }
            $test_response['notrun'] = $nnotrun;
            $test_response['fail'] = $nfail;
            $test_response['pass'] = $npass;
            $buildgroups_response[$i]['numtestnotrun'] += $nnotrun;
            $buildgroups_response[$i]['numtestfail'] += $nfail;
            $buildgroups_response[$i]['numtestpass'] += $npass;
            $test_response['time'] = time_difference($testduration, true);
            $test_response['timefull'] = $testduration;
            $buildgroups_response[$i]['testduration'] += $testduration;
            $build_response['test'] = $test_response;
        }
        $starttimestamp = strtotime($build_array['starttime'] . ' UTC');
        $submittimestamp = strtotime($build_array['submittime'] . ' UTC');
        // Use the default timezone.
        $build_response['builddatefull'] = $starttimestamp;
        // If the data is more than 24h old then we switch from an elapsed to a normal representation
        if (time() - $starttimestamp < 86400) {
            $build_response['builddate'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
            $build_response['builddateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago');
        } else {
            $build_response['builddateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
            $build_response['builddate'] = time_difference(time() - $starttimestamp, false, 'ago');
        }
        $build_response['submitdate'] = date(FMT_DATETIMEDISPLAY, $submittimestamp);
        // Generate a string summarizing this build's timing.
        $timesummary = $build_response['builddate'];
        if ($build_response['hasupdate'] && array_key_exists('time', $build_response['update'])) {
            $timesummary .= ', Update time: ' . $build_response['update']['time'];
        }
        if ($build_response['hasconfigure'] && array_key_exists('time', $build_response['configure'])) {
            $timesummary .= ', Configure time: ' . $build_response['configure']['time'];
        }
        if ($build_response['hascompilation'] && array_key_exists('time', $build_response['compilation'])) {
            $timesummary .= ', Build time: ' . $build_response['compilation']['time'];
        }
        if ($build_response['hastest'] && array_key_exists('time', $build_response['test'])) {
            $timesummary .= ', Test time: ' . $build_response['test']['time'];
        }
        $timesummary .= ', Total time: ' . $build_response['time'];
        $build_response['timesummary'] = $timesummary;
        if ($include_subprojects || $exclude_subprojects) {
            // Check if this build should be filtered out now that its
            // numbers have been updated by the SubProject include/exclude
            // filter.
            if (!build_survives_filter($build_response, $filterdata)) {
                continue;
            }
        }
        if ($build_array['name'] != 'Aggregate Coverage') {
            $buildgroups_response[$i]['builds'][] = $build_response;
        }
        // Coverage
        //
        // Determine if this is a parent build with no actual coverage of its own.
        $linkToChildCoverage = false;
        if ($numchildren > 0) {
            $countChildrenResult = pdo_single_row_query('SELECT count(fileid) AS nfiles FROM coverage
                    WHERE buildid=' . qnum($buildid));
            if ($countChildrenResult['nfiles'] == 0) {
                $linkToChildCoverage = true;
            }
        }
        $coverageIsGrouped = false;
        $loctested = $build_array['loctested'];
        $locuntested = $build_array['locuntested'];
        if ($loctested + $locuntested > 0) {
            $coverage_response = array();
            $coverage_response['buildid'] = $build_array['id'];
            if ($linkToChildCoverage) {
                $coverage_response['childlink'] = "{$child_builds_hyperlink}##Coverage";
            }
            if ($build_array['type'] === 'Nightly' && $build_array['name'] !== 'Aggregate Coverage') {
                $num_nightly_coverages_builds++;
                if ($num_nightly_coverages_builds > 1) {
                    $show_aggregate = true;
                    if ($linkToChildCoverage) {
                        $response['comparecoverage'] = 1;
                    }
                }
            }
            $percent = round(compute_percentcoverage($loctested, $locuntested), 2);
            if ($build_array['subprojectgroup']) {
                $groupId = $build_array['subprojectgroup'];
                if (array_key_exists($groupId, $coverage_groups)) {
                    $coverageIsGrouped = true;
                    $coverageThreshold = $coverage_groups[$groupId]['thresholdgreen'];
                    $coverage_groups[$groupId]['loctested'] += $loctested;
                    $coverage_groups[$groupId]['locuntested'] += $locuntested;
                    if (count($coverage_groups) > 1) {
                        // Add to Total.
                        $coverage_groups[0]['loctested'] += $loctested;
                        $coverage_groups[0]['locuntested'] += $locuntested;
                    }
                }
            }
            $coverage_response['percentage'] = $percent;
            $coverage_response['locuntested'] = intval($locuntested);
            $coverage_response['loctested'] = intval($loctested);
            // Compute the diff
            if (!empty($build_array['loctesteddiff'])) {
                $loctesteddiff = $build_array['loctesteddiff'];
                $locuntesteddiff = $build_array['locuntesteddiff'];
                @($previouspercent = round(($loctested - $loctesteddiff) / ($loctested - $loctesteddiff + $locuntested - $locuntesteddiff) * 100, 2));
                $percentdiff = round($percent - $previouspercent, 2);
                $coverage_response['percentagediff'] = $percentdiff;
                $coverage_response['locuntesteddiff'] = $locuntesteddiff;
                $coverage_response['loctesteddiff'] = $loctesteddiff;
            }
            $starttimestamp = strtotime($build_array['starttime'] . ' UTC');
            $coverage_response['datefull'] = $starttimestamp;
            // If the data is more than 24h old then we switch from an elapsed to a normal representation
            if (time() - $starttimestamp < 86400) {
                $coverage_response['date'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $coverage_response['dateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago');
            } else {
                $coverage_response['dateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $coverage_response['date'] = time_difference(time() - $starttimestamp, false, 'ago');
            }
            // Are there labels for this build?
            //
            $coverage_response['label'] = $build_label;
            if ($coverageIsGrouped) {
                $coverage_groups[$groupId]['coverages'][] = $coverage_response;
            } else {
                $coverage_response['site'] = $build_array['sitename'];
                $coverage_response['buildname'] = $build_array['name'];
                $response['coverages'][] = $coverage_response;
            }
        }
        if (!$coverageIsGrouped) {
            $coverageThreshold = $project_array['coveragethreshold'];
            $response['thresholdgreen'] = $coverageThreshold;
            $response['thresholdyellow'] = $coverageThreshold * 0.7;
        }
        // Dynamic Analysis
        //
        if (!empty($build_array['checker'])) {
            // Determine if this is a parent build with no dynamic analysis
            // of its own.
            $linkToChildren = false;
            if ($numchildren > 0) {
                $countChildrenResult = pdo_single_row_query('SELECT count(id) AS num FROM dynamicanalysis
                        WHERE buildid=' . qnum($build_array['id']));
                if ($countChildrenResult['num'] == 0) {
                    $linkToChildren = true;
                }
            }
            $DA_response = array();
            $DA_response['site'] = $build_array['sitename'];
            $DA_response['buildname'] = $build_array['name'];
            $DA_response['buildid'] = $build_array['id'];
            $DA_response['checker'] = $build_array['checker'];
            $DA_response['defectcount'] = $build_array['numdefects'];
            $starttimestamp = strtotime($build_array['starttime'] . ' UTC');
            $DA_response['datefull'] = $starttimestamp;
            if ($linkToChildren) {
                $DA_response['childlink'] = "{$child_builds_hyperlink}##DynamicAnalysis";
            }
            // If the data is more than 24h old then we switch from an elapsed to a normal representation
            if (time() - $starttimestamp < 86400) {
                $DA_response['date'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $DA_response['dateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago');
            } else {
                $DA_response['dateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $DA_response['date'] = time_difference(time() - $starttimestamp, false, 'ago');
            }
            // Are there labels for this build?
            //
            $DA_response['label'] = $build_label;
            $response['dynamicanalyses'][] = $DA_response;
        }
    }
    // Put some finishing touches on our buildgroups now that we're done
    // iterating over all the builds.
    $addExpected = empty($filter_sql) && pdo_num_rows($builds) + count($dynamic_builds) > 0;
    for ($i = 0; $i < count($buildgroups_response); $i++) {
        $buildgroups_response[$i]['testduration'] = time_difference($buildgroups_response[$i]['testduration'], true);
        $num_expected_builds = 0;
        if (!$filter_sql) {
            $groupname = $buildgroups_response[$i]['name'];
            $expected_builds = add_expected_builds($buildgroups_response[$i]['id'], $currentstarttime, $received_builds[$groupname]);
            if (is_array($expected_builds)) {
                $num_expected_builds = count($expected_builds);
                $buildgroups_response[$i]['builds'] = array_merge($buildgroups_response[$i]['builds'], $expected_builds);
            }
        }
        // Show how many builds this group has.
        $num_builds = count($buildgroups_response[$i]['builds']);
        $num_builds_label = '';
        if ($num_expected_builds > 0) {
            $num_actual_builds = $num_builds - $num_expected_builds;
            $num_builds_label = "{$num_actual_builds} of {$num_builds} builds";
        } else {
            if ($num_builds === 1) {
                $num_builds_label = '1 build';
            } else {
                $num_builds_label = "{$num_builds} builds";
            }
        }
        $buildgroups_response[$i]['numbuildslabel'] = $num_builds_label;
    }
    // Create a separate "all buildgroups" section of our response.
    // This is used to allow project admins to move builds between groups.
    $response['all_buildgroups'] = array();
    foreach ($buildgroups_response as $group) {
        $response['all_buildgroups'][] = array('id' => $group['id'], 'name' => $group['name']);
    }
    // At this point it is safe to remove any empty buildgroups from our response.
    function is_buildgroup_nonempty($group)
    {
        return !empty($group['builds']);
    }
    $buildgroups_response = array_filter($buildgroups_response, 'is_buildgroup_nonempty');
    // Report buildgroups as a list, not an associative array.
    // Otherwise any missing buildgroups will cause our view to
    // not honor the order specified by the project admins.
    $buildgroups_response = array_values($buildgroups_response);
    // Remove Aggregate Coverage if it should not be displayed.
    if (!$show_aggregate) {
        for ($i = 0; $i < count($response['coverages']); $i++) {
            if ($response['coverages'][$i]['buildname'] === 'Aggregate Coverage') {
                unset($response['coverages'][$i]);
            }
        }
        $response['coverages'] = array_values($response['coverages']);
    }
    if ($response['childview'] == 1) {
        // Report number of children.
        if (!empty($buildgroups_response)) {
            $numchildren = count($buildgroups_response[0]['builds']);
        } else {
            $row = pdo_single_row_query('SELECT count(id) AS numchildren
                    FROM build WHERE parentid=' . qnum($parentid));
            $numchildren = $row['numchildren'];
        }
        $response['numchildren'] = $numchildren;
    }
    // Generate coverage by group here.
    if (!empty($coverage_groups)) {
        $response['coveragegroups'] = array();
        foreach ($coverage_groups as $groupid => $group) {
            $loctested = $group['loctested'];
            $locuntested = $group['locuntested'];
            if ($loctested == 0 && $locuntested == 0) {
                continue;
            }
            $percentage = round($loctested / ($loctested + $locuntested) * 100, 2);
            $group['percentage'] = $percentage;
            $group['id'] = $groupid;
            $response['coveragegroups'][] = $group;
        }
    }
    $response['buildgroups'] = $buildgroups_response;
    $response['enableTestTiming'] = $project_array['showtesttime'];
    $end = microtime_float();
    $response['generationtime'] = round($end - $start, 3);
    if (!empty($site_response)) {
        $response = array_merge($response, $site_response);
    }
    echo json_encode(cast_data_for_JSON($response));
}
 private function fetchBuild($slug, $build)
 {
     $response = array();
     if (Cache::has('modpack.' . $slug) && empty($this->client) && empty($this->key)) {
         $modpack = Cache::Get('modpack.' . $slug);
     } else {
         $modpack = Modpack::where("slug", "=", $slug)->first();
         if (empty($this->client) && empty($this->key)) {
             Cache::put('modpack.' . $slug, $modpack, 5);
         }
     }
     if (empty($modpack)) {
         return array("error" => "Modpack does not exist");
     }
     $buildpass = $build;
     if (Cache::has('modpack.' . $slug . '.build.' . $build) && empty($this->client) && empty($this->key)) {
         $build = Cache::get('modpack.' . $slug . '.build.' . $build);
     } else {
         $build = Build::with('Modversions')->where("modpack_id", "=", $modpack->id)->where("version", "=", $build)->first();
         if (empty($this->client) && empty($this->key)) {
             Cache::put('modpack.' . $slug . '.build.' . $buildpass, $build, 5);
         }
     }
     if (empty($build)) {
         return array("error" => "Build does not exist");
     }
     $response['minecraft'] = $build->minecraft;
     $response['minecraft_md5'] = $build->minecraft_md5;
     $response['java'] = $build->min_java;
     $response['memory'] = $build->min_memory;
     $response['forge'] = $build->forge;
     $response['mods'] = array();
     if (!Input::has('include')) {
         if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion') && empty($this->client) && empty($this->key)) {
             $response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion');
         } else {
             foreach ($build->modversions as $modversion) {
                 $response['mods'][] = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5, "url" => Config::get('solder.mirror_url') . 'mods/' . $modversion->mod->name . '/' . $modversion->mod->name . '-' . $modversion->version . '.zip');
             }
             usort($response['mods'], function ($a, $b) {
                 return strcasecmp($a['name'], $b['name']);
             });
             Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion', $response['mods'], 5);
         }
     } else {
         if (Input::get('include') == "mods") {
             if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods') && empty($this->client) && empty($this->key)) {
                 $response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods');
             } else {
                 foreach ($build->modversions as $modversion) {
                     $response['mods'][] = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5, "pretty_name" => $modversion->mod->pretty_name, "author" => $modversion->mod->author, "description" => $modversion->mod->description, "link" => $modversion->mod->link, "donate" => $modversion->mod->donatelink, "url" => Config::get('solder.mirror_url') . 'mods/' . $modversion->mod->name . '/' . $modversion->mod->name . '-' . $modversion->version . '.zip');
                 }
                 usort($response['mods'], function ($a, $b) {
                     return strcasecmp($a['name'], $b['name']);
                 });
                 Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.mods', $response['mods'], 5);
             }
         } else {
             $request = explode(",", Input::get('include'));
             if (Cache::has('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request) && empty($this->client) && empty($this->key)) {
                 $response['mods'] = Cache::get('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request);
             } else {
                 foreach ($build->modversions as $modversion) {
                     $data = array("name" => $modversion->mod->name, "version" => $modversion->version, "md5" => $modversion->md5);
                     $mod = (array) $modversion->mod;
                     $mod = $mod['attributes'];
                     foreach ($request as $type) {
                         if (isset($mod[$type])) {
                             $data[$type] = $mod[$type];
                         }
                     }
                     $response['mods'][] = $data;
                 }
                 usort($response['mods'], function ($a, $b) {
                     return strcasecmp($a['name'], $b['name']);
                 });
                 Cache::put('modpack.' . $slug . '.build.' . $buildpass . 'modversion.include.' . $request, $response['mods'], 5);
             }
         }
     }
     return $response;
 }
示例#29
0
$siteid = $build_array['siteid'];
$buildtype = $build_array['type'];
$buildname = $build_array['name'];
$starttime = $build_array['starttime'];
$threshold = $project_array['coveragethreshold'];
if ($build_array['groupid'] > 0) {
    $row = pdo_single_row_query('SELECT coveragethreshold FROM subprojectgroup
     WHERE projectid=' . qnum($projectid) . '
     AND id=' . qnum($build_array['groupid']));
    if (!empty($row) && isset($row['coveragethreshold'])) {
        $threshold = $row['coveragethreshold'];
    }
}
$xml .= '<menu>';
$xml .= add_XML_value('back', 'index.php?project=' . urlencode($projectname) . '&date=' . get_dashboard_date_from_build_starttime($build_array['starttime'], $project_array['nightlytime']));
$build = new Build();
$build->Id = $buildid;
$previous_buildid = $build->GetPreviousBuildId();
$current_buildid = $build->GetCurrentBuildId();
$next_buildid = $build->GetNextBuildId();
if ($previous_buildid > 0) {
    $xml .= add_XML_value('previous', 'viewCoverage.php?buildid=' . $previous_buildid);
} else {
    $xml .= add_XML_value('noprevious', '1');
}
$xml .= add_XML_value('current', "viewCoverage.php?buildid={$current_buildid}");
if ($next_buildid > 0) {
    $xml .= add_XML_value('next', "viewCoverage.php?buildid={$next_buildid}");
} else {
    $xml .= add_XML_value('nonext', '1');
}
示例#30
0
文件: user.php 项目: rpshaw/CDash
 /** Report statistics about the last build */
 function ReportLastBuild($type, $projectid, $siteid, $projectname, $nightlytime)
 {
     $xml = "<" . strtolower($type) . ">";
     $nightlytime = strtotime($nightlytime);
     // Find the last build
     $build = pdo_query("SELECT starttime,id FROM build WHERE siteid='{$siteid}' AND projectid='{$projectid}' AND type='{$type}' ORDER BY submittime DESC LIMIT 1");
     if (pdo_num_rows($build) > 0) {
         $build_array = pdo_fetch_array($build);
         $buildid = $build_array["id"];
         // Express the date in terms of days (makes more sens)
         $buildtime = strtotime($build_array["starttime"] . " UTC");
         $builddate = $buildtime;
         if (date(FMT_TIME, $buildtime) > date(FMT_TIME, $nightlytime)) {
             $builddate += 3600 * 24;
             //next day
         }
         if (date(FMT_TIME, $nightlytime) < '12:00:00') {
             $builddate -= 3600 * 24;
             // previous date
         }
         $date = date(FMT_DATE, $builddate);
         $days = (time() - strtotime($date)) / (3600 * 24);
         if ($days < 1) {
             $day = "today";
         } else {
             if ($days > 1 && $days < 2) {
                 $day = "yesterday";
             } else {
                 $day = round($days) . " days";
             }
         }
         $xml .= add_XML_value("date", $day);
         $xml .= add_XML_value("datelink", "index.php?project=" . urlencode($projectname) . "&date=" . $date);
         // Configure
         $configure = pdo_query("SELECT status FROM configure WHERE buildid='{$buildid}'");
         if (pdo_num_rows($configure) > 0) {
             $configure_array = pdo_fetch_array($configure);
             $xml .= add_XML_value("configure", $configure_array["status"]);
             if ($configure_array["status"] != 0) {
                 $xml .= add_XML_value("configureclass", "error");
             } else {
                 $xml .= add_XML_value("configureclass", "normal");
             }
         } else {
             $xml .= add_XML_value("configure", "-");
             $xml .= add_XML_value("configureclass", "normal");
         }
         // Update
         $update = pdo_query("SELECT uf.updateid FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=" . $buildid);
         $nupdates = pdo_num_rows($update);
         $xml .= add_XML_value("update", $nupdates);
         // Find locally modified files
         $updatelocal = pdo_query("SELECT uf.updateid FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=" . $buildid . " AND uf.author='Local User'");
         // Set the color
         if (pdo_num_rows($updatelocal) > 0) {
             $xml .= add_XML_value("updateclass", "error");
         } else {
             $xml .= add_XML_value("updateclass", "normal");
         }
         // Find the number of errors and warnings
         $Build = new Build();
         $Build->Id = $buildid;
         $nerrors = $Build->GetNumberOfErrors();
         $xml .= add_XML_value("error", $nerrors);
         $nwarnings = $Build->GetNumberOfWarnings();
         $xml .= add_XML_value("warning", $nwarnings);
         // Set the color
         if ($nerrors > 0) {
             $xml .= add_XML_value("errorclass", "error");
         } else {
             if ($nwarnings > 0) {
                 $xml .= add_XML_value("errorclass", "warning");
             } else {
                 $xml .= add_XML_value("errorclass", "normal");
             }
         }
         // Find the test
         $nnotrun = $Build->GetNumberOfNotRunTests();
         $nfail = $Build->GetNumberOfFailedTests();
         // Display the failing tests then the not run
         if ($nfail > 0) {
             $xml .= add_XML_value("testfail", $nfail);
             $xml .= add_XML_value("testfailclass", "error");
         } else {
             if ($nnotrun > 0) {
                 $xml .= add_XML_value("testfail", $nnotrun);
                 $xml .= add_XML_value("testfailclass", "warning");
             } else {
                 $xml .= add_XML_value("testfail", "0");
                 $xml .= add_XML_value("testfailclass", "normal");
             }
         }
         $xml .= add_XML_value("NA", "0");
     } else {
         $xml .= add_XML_value("NA", "1");
     }
     $xml .= "</" . strtolower($type) . ">";
     return $xml;
 }