function test_install_with_invalid_spark_version() { $clines = $this->capture_buffer_lines(function ($cli) { $cli->execute('install', array('v9.4', 'example-spark')); }); $success = (bool) (strpos(reset($clines), chr(27) . '[1;31m[ ERROR ]' . chr(27) . '[0m Uh-oh!') === 0); Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark'); $this->assertEquals(true, $success); }
function retrieve() { `hg clone -r{$this->tag} {$this->base_location} {$this->temp_path}`; // remove the mercurial directory Spark_utils::remove_full_directory("{$this->temp_path}/.hg"); if (!file_exists($this->temp_path)) { throw new Spark_exception('Failed to retrieve the spark ;('); } return true; }
function test_remove_with_invalid_version() { $clines = $this->capture_buffer_lines(function ($cli) { $cli->execute('install', array('-v1.0', 'example-spark')); // Spark needs installed first $cli->execute('remove', array('-v9.4', 'example-spark')); }); $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' . chr(27) . '[0m Looks like that spark isn\'t installed') === 0 && is_dir(SPARK_PATH . '/example-spark')); $this->assertEquals(true, $success); Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark'); }
function retrieve() { // check out the right tag `git clone --recursive {$this->base_location} {$this->temp_path}`; `cd {$this->temp_path}; git checkout {$this->tag} -b {$this->temp_token}`; // remove the git directory Spark_utils::remove_full_directory("{$this->temp_path}/.git"); if (!file_exists($this->temp_path)) { throw new Spark_exception('Failed to retrieve the spark ;('); } return true; }
function install() { foreach ($this->dependencies as $dependency) { if ($dependency->is_direct) { $this->install_dependency($dependency); } } @mkdir(SPARK_PATH); // Two steps for windows @mkdir(SPARK_PATH . "/{$this->name}"); Spark_utils::full_move($this->temp_path, $this->installation_path); Spark_utils::remove_full_directory($this->temp_path); $this->installed_path = $this->installation_path; }
private function remove($args) { list($flats, $flags) = $this->prep_args($args); if (count($flats) != 1) { return $this->failtown('Which spark do you want to remove?'); } $spark_name = $flats[0]; $version = array_key_exists('v', $flags) ? $flags['v'] : null; // figure out what to remove and make sure its isntalled $dir_to_remove = SPARK_PATH . ($version == null ? "/{$spark_name}" : "/{$spark_name}/{$version}"); if (!file_exists($dir_to_remove)) { return Spark_utils::warning('Looks like that spark isn\'t installed'); } if ($version == null && !array_key_exists('f', $flags)) { throw new Spark_exception("Please specify a version (spark remove -v1.0.0 foo) or remove all with -f"); } Spark_utils::notice("Removing {$spark_name} (" . ($version ? $version : 'ALL') . ") from {$dir_to_remove}"); if (Spark_utils::remove_full_directory($dir_to_remove, true)) { Spark_utils::notice('Spark removed successfully!'); } else { Spark_utils::warning('Looks like that spark isn\'t installed'); } // attempt to clean up - will not remove unless empty @rmdir(SPARK_PATH . "/{$spark_name}"); }
function tearDown() { if (is_dir(SPARK_PATH . '/example-spark')) { Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark'); } }