/** * Sets up test case - initializes directory in %TEMP * */ public function setUp() { $this->temp = $this->normalize(realpath(System::tempDir())) . md5(uniqid()) . '.xp' . DIRECTORY_SEPARATOR; if (is_dir($this->temp) && !rmdir($this->temp)) { throw new \unittest\PrerequisitesNotMetError('Fixture directory exists, but cannot remove', null, $this->temp); } }
/** * Sets up test case */ public function setUp() { $this->emitter = new V54Emitter(); $this->files = new FileManager(); $this->files->addSourcePath(dirname(__FILE__) . '/src'); // FIXME: ClassPathManager? $this->files->setOutput(new \io\Folder(\lang\System::tempDir())); }
public function setUp() { $tempDir = realpath(System::tempDir()); $this->fixture = new FilesystemPropertySource($tempDir); // Create a temporary ini file $this->tempFile = new File($tempDir, 'temp.ini'); FileUtil::setContents($this->tempFile, "[section]\nkey=value\n"); }
public static function createFiles() { self::$temp = new Folder(System::tempDir(), uniqid(microtime(true))); self::$temp->create(); $partials = new Folder(self::$temp, 'partials'); $partials->create(); FileUtil::setContents(new File(self::$temp, 'test.mustache'), 'Mustache template {{id}}'); FileUtil::setContents(new File($partials, 'navigation.mustache'), '{{#if nav}}nav{{/if}}'); }
public static function makeConfigDirectory() { self::$dir = realpath(System::tempDir()) . DIRECTORY_SEPARATOR . md5(uniqid()) . '.xp' . DIRECTORY_SEPARATOR; if (is_dir(self::$dir) && !rmdir(self::$dir)) { throw new PrerequisitesNotMetError('Fixture directory exists, but cannot remove', null, self::$dir); } self::$file = self::$dir . 'web.ini'; mkdir(self::$dir); file_put_contents(self::$file, '[app]'); }
public static function verifyTempDir() { self::$temp = System::tempDir(); if (!is_writeable(self::$temp)) { throw new \unittest\PrerequisitesNotMetError('$TEMP is not writeable', null, array(self::$temp . ' +w')); } if (($df = disk_free_space(self::$temp)) < 10240) { throw new \unittest\PrerequisitesNotMetError('Not enough space available in $TEMP', null, array(sprintf('df %s = %.0fk > 10k', self::$temp, $df / 1024))); } }
/** * Sets up test case - initializes temp directory in %TEMP% * * @return void */ public function setUp() { $this->folder = new Folder(System::tempDir(), md5(uniqid()) . '.xp'); $this->folder->exists() && $this->folder->unlink(); $this->folder->create(); }
public function runningDirectory() { new Process(System::tempDir()); }
public function links_resolved_in_realpath() { $temp = System::tempDir(); $link = new Path($temp, 'link-to-temp'); if (false === symlink($temp, $link)) { $this->skip('Cannot create ' . $link . ' -> ' . $temp); } $resolved = (new Path($link))->asRealpath()->toString(); unlink($link); $this->assertEquals($temp, $resolved); }
/** @param io.Path */ private function tempName() { return Path::compose([System::tempDir(), md5(uniqid()) . '-xp.json']); }
public static function prepareTempDir() { self::$temp = new Folder(System::tempDir(), md5(uniqid())); self::$temp->create(); session_save_path(self::$temp->getURI()); }
/** * Main runner method * * @param string[] args */ public static function main(array $args) { if (!$args) { self::usage(); } // Parse arguments $output = '-'; for ($i = 0, $s = sizeof($args); $i < $s; $i++) { if ('-O' == $args[$i]) { $output = $args[++$i]; } else { if ('-?' == $args[$i] || '--help' == $args[$i]) { self::usage(); } else { $package = $args[$i]; break; } } } // Load generator class try { $class = \lang\reflect\Package::forName('xp.codegen')->getPackage($package)->loadClass('Generator'); } catch (\lang\ElementNotFoundException $e) { Console::$err->writeLine('*** No generator named "' . $package . '"'); exit(2); } $params = new ParamString(array_slice($args, $i + 1)); if ($params->exists('help', '?')) { Console::$err->writeLine(self::textOf($class->getComment())); exit(1); } // Instantiate generator $generator = $class->newInstance($params); $generator->storage = new FileSystemStorage(System::tempDir()); // Output if ('-' === $output) { $generator->output = new ConsoleOutput(Console::$err); } else { if (strstr($output, '.xar')) { $generator->output = new ArchiveOutput($output); } else { $generator->output = new FileSystemOutput($output); } } $generator->output->addObserver(newinstance('util.Observer', array(), '{ public function update($obs, $arg= NULL) { Console::writeLine(" >> ", $arg); } }')); Console::writeLine('===> Starting ', $generator); // Compile target chain $empty = new \lang\types\ArrayList(); $targets = create('new util.collections.HashTable<lang.reflect.Method, util.collections.HashTable<string, lang.Generic>>()'); foreach ($class->getMethods() as $method) { if (!$method->hasAnnotation('target')) { continue; } $target = create('new util.collections.HashTable<string, lang.Generic>()'); // Fetch dependencies if ($method->hasAnnotation('target', 'depends')) { $depends = create('new util.collections.Vector<lang.reflect.Method>()'); foreach ((array) $method->getAnnotation('target', 'depends') as $dependency) { $depends[] = $class->getMethod($dependency); } $target['depends'] = $depends; } // Fetch input if ($method->hasAnnotation('target', 'input')) { $arguments = create('new util.collections.Vector<lang.reflect.Method>()'); foreach ((array) $method->getAnnotation('target', 'input') as $input) { $arguments[] = $class->getMethod($input); } $target['arguments'] = $arguments; } $targets->put($method, $target); } // Invoke try { foreach ($targets->keys() as $method) { self::invoke($generator, $method, $targets); } } catch (\lang\reflect\TargetInvocationException $e) { Console::$err->writeLine('*** ', $e->getCause()); exit(3); } $generator->output->commit(); Console::writeLine('===> Done'); }
public function callingMain() { $temp = System::tempDir(); // Create web.ini in system's temp dir $ini = new \io\File($temp, 'web.ini'); $ini->open(FILE_MODE_WRITE); $ini->write("[app]\n" . "mappings=\"/:welcome\"\n" . "[app::welcome]\n" . "class=undefined\n" . "[app::welcome@dev]\n" . "class=\"" . self::$welcomeScriptlet->getName() . "\"\n"); $ini->close(); // Run ob_start(); Runner::main(array($temp, $temp, 'dev', '/')); $content = ob_get_contents(); ob_end_clean(); $ini->unlink(); // Assert $this->assertEquals('<h1>Welcome, we are open</h1>', $content); }
/** * Constructor * * @param string $prefix default "tmp" */ public function __construct($prefix = 'tmp') { parent::__construct(tempnam(System::tempDir(), $prefix . uniqid((double) microtime()))); }