function check_prerequisites() { return check_for_plugin("tests/" . $this->plugin_name); }
function create_label_struct($directory, $label_filename, $third_party_filename) { global $default_labels; global $non_default_labels; global $opposite_label; global $labels; global $exceptions; global $opt_one; $files = get_all_scripts_in_dir($directory); // labelled files is a table indexed by filename, containing tables indexed // by default labels, which are set to 1 or 0 for default and non-default // respectively foreach ($default_labels as $default) { foreach ($files as $filename) { $labelled_files[$filename][$default] = 1; } } foreach ($files as $filename) { $labelled_files[$filename]["non-interpretable"] = "check"; } // parse the file $lines = file($label_filename); if (file_exists($third_party_filename)) { $third_party_lines = file($third_party_filename); } else { $third_party_lines = array(); } foreach ($lines as $line) { $line = preg_replace("/#.*\$/", "", $line); // remove comments $line = trim($line); // remove superfluous whitespace if ($line == "") { continue; } // skip blank lines process_label_file_line($line, $files, $labelled_files); } foreach ($third_party_lines as $line) { $line = preg_replace("/#.*\$/", "", $line); // remove comments $line = trim($line); // remove superfluous whitespace if ($line == "") { continue; } // skip blank lines process_label_file_line("3rdparty/" . $line, $files, $labelled_files); } # if -O is provided, remove all other files if ($opt_one) { foreach ($labelled_files as $key => $value) { if ($key !== $opt_one) { unset($labelled_files[$key]); $files = array($opt_one); } } } # init the label struct foreach ($labels as $label) { $label_struct[$label] = array(); } # go over the labelled_files, and make an table indexed by label foreach ($files as $filename) { // If you have a ton of 3rd party files, dont spend time checking them // all, unless your actually going to use them if (skip_3rdparty($filename)) { $labelled_files[$filename]["non-interpretable"] = 0; } else { phc_assert(isset($labelled_files[$filename]), "file not found"); // check the interpretable if ($labelled_files[$filename]["non-interpretable"] === "check") { phc_assert(check_for_plugin("tools/purity_test"), "purity not available"); global $phc, $plugin_dir; if (`{$phc} --run {$plugin_dir}/tools/purity_test.la {$filename} 2>&1` == "") { log_status("pure", "", $filename, ""); $labelled_files[$filename]["non-interpretable"] = 0; } else { log_status("impure", "", $filename, ""); $labelled_files[$filename]["non-interpretable"] = 1; } } } foreach ($default_labels as $label) { if ($labelled_files[$filename][$label]) { array_push($label_struct[$label], $filename); } else { array_push($label_struct[$opposite_label[$label]], $filename); } } } // sort and generally fix up the arrays foreach ($labels as $label) { sort($label_struct[$label]); } return $label_struct; }