$flag_ownSrc = 0; } $path = $i . '.js'; $srcFile = Config::$projroot . Config::$src_PATH . $path; if (file_exists($srcFile)) { echo "document.write('<script charset=utf-8 src=\"{$srcFile}\"></script>');\n"; } } if (file_exists($this_src)) { $file = fopen($this_src, "r"); while (!feof($file)) { $statment = fgets($file); if (custom_strEmpty($statment)) { continue; } else { if (preg_match('/\\/\\/\\/import\\s+([^;]+);?/ies', $statment, $r)) { echo "document.write('<script charset=utf-8 src=\"" . Config::$projroot . Config::$src_PATH . $r[1] . ".js\"></script>');\n"; } else { break; } } } fclose($file); } //加载与用例同名的原文件,并避免重复加载 if ($flag_ownSrc) { echo "document.write('<script charset=utf-8 src=\"" . $this_src . "\"></script>');\n"; } } importSrc();
$covpath = Config::$COVERAGE_PATH . $path; if (file_exists($covpath)) { if (Config::$DEBUG) { var_dump($covpath); } $_source = file_get_contents($covpath); $source .= $_source; } else { if (Config::$DEBUG) { print "fail read file : " . Config::$COVERAGE_PATH . $path; } } } else { foreach (Config::$SOURCE_PATH as $i => $d) { // if(preg_match("/editorui/",$dd)){ // echo "*************".file_get_contents($d.$path)."************"; // } if (file_exists($d . $path)) { $source .= file_get_contents($d . $path); $source .= "\n"; //读取文件内容必须加个回车 break; } } } } return $source; } //update by bell 2011-03-25, 更新覆盖率相关逻辑 echo importSrc($cov);
return ""; } } array_push($IGNORE, $d); $ccnt = Analysis::get_src_cnt($d, $cov); if ($dep) { return preg_replace("/\\/\\/\\/import\\s+(magic(\\.[\\w\\-\$]+)*);?/ies", "importSrc('\\1', {$dep})", $ccnt['c']); } else { return preg_replace("/\\/\\/\\/import\\s+([\\w\\-\$]+(\\.[\\w\\-\$]+)*);?/ies", "importSrc('\\1')", $ccnt['c']); } } //update by bell 2011-03-25, 更新覆盖率相关逻辑 if (!$cov) { $cnt = ""; foreach ($f as $d) { $cnt .= importSrc($d, $dep, $cov); } echo $cnt; } else { $IMPORT_LIST = array(); foreach ($f as $d) { if (Config::$DEBUG) { var_dump($d); } $IMPORT_LIST = array_merge($IMPORT_LIST, array_keys($analysis->get_import_srcs($d))); } if (Config::$DEBUG) { var_dump('after analysis', $IMPORT_LIST); } else { foreach ($IMPORT_LIST as $d) { if (array_search($d, $IGNORE)) {
*/ $import = 'import.js'; function importSrc() { global $import; $source = ''; require_once 'config.php'; if (file_exists(Config::$projroot . Config::$test_PATH . $import)) { $cnt = file_get_contents(Config::$projroot . Config::$test_PATH . $import); } if ($cnt == '') { if (Config::$DEBUG) { print "fail read file : " . Config::$test_PATH . $import; } return ''; } $is = array(); //正则匹配,提取所有(///import xxx;)中的xxx preg_match_all('/\\/\\/\\/import\\s+([^;]+);?/ies', $cnt, $is, PREG_PATTERN_ORDER); foreach ($is[1] as $i) { $path = $i . '.js'; if (file_exists(Config::$projroot . Config::$src_PATH . $path)) { $source .= file_get_contents(Config::$projroot . Config::$src_PATH . $path); $source .= "\n"; //读取文件内容必须加个回车 } } return $source; } echo importSrc();
foreach ($is[1] as $i) { $path = join('/', explode('.', $i)) . '.js'; if ($cov) { $covpath = Config::$COVERAGE_PATH . $path; if (file_exists($covpath)) { if (Config::$DEBUG) { var_dump($covpath); } $source .= file_get_contents($covpath); } else { print "fail read file : " . Config::$COVERAGE_PATH . $path; } } else { foreach (Config::$SOURCE_PATH as $i => $d) { if (file_exists($d . $path)) { $source .= file_get_contents($d . $path); $source .= "\n"; //读取文件内容必须加个回车 break; } } } } return $source; } //update by bell 2011-03-25, 更新覆盖率相关逻辑 if (!$cov) { echo importSrc(); } else { echo importSrc(true); }
} array_push($IGNORE, $d); // $ccnt = Analysis::get_src_cnt($d, $cov); // return $ccnt['c']; // return preg_replace("/\/\/\/import\s+([\w\-\$]+(\.[\w\-\$]+)*);?/ies", "importSrc('\\1')", $ccnt['c']); $ccnt = $analysis->get_import_srcs($d); //jiangshuguang修改 返回某个js所有的依赖的js return implode($ccnt, ";"); } //update by bell 2011-03-25, 更新覆盖率相关逻辑 if (!$cov) { $cnt = ""; foreach ($f as $d) { $d = preg_replace('/\\s*/', '', $d) . '.js'; //jiangshuguang修改 $cnt .= ";" . importSrc($d, $cov); } echo $cnt; } else { $IMPORT_LIST = array(); foreach ($f as $d) { if (ConfigTest::$DEBUG) { var_dump($d); } $d = preg_replace('/\\s*/', '', $d) . '.js'; //jiangshuguang修改 $IMPORT_LIST = array_merge($IMPORT_LIST, array_keys($analysis->get_import_srcs($d))); } if (ConfigTest::$DEBUG) { var_dump('after analysis', $IMPORT_LIST); } else {