Permalink
Browse files

Debug compiler & Tests

  • Loading branch information...
1 parent b057607 commit d267bd2b9c5b545e2e4ef673cdcd3bb56d0d4ddc Xavier HAUSHERR committed Apr 5, 2012
View
3 .gitmodules
@@ -1,3 +1,6 @@
[submodule "Fixtures/symfony"]
path = Fixtures/symfony
url = git://github.com/symfony/symfony.git
+[submodule "Fixtures/thrift"]
+ path = Fixtures/thrift
+ url = git@github.com:ebuzzing/thrift.git
View
2 CacheWarmer/ThriftCompileCacheWarmer.php
@@ -88,7 +88,7 @@ public function warmUp($cacheDir)
$compiler->setModelPath(sprintf('%s/%s', $this->cacheDir, self::CACHE_SUFFIX));
// Empty old model
- $compiler->emptyModelPath($config['definition']);
+ $compiler->emptyModelPath($config['namespace']);
$compiler->compile($definitionPath, $config['server']);
}
View
14 Command/CompileCommand.php
@@ -8,6 +8,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Overblog\ThriftBundle\Compiler\ThriftCompiler;
+use Overblog\ThriftBundle\CacheWarmer\ThriftCompileCacheWarmer;
/**
* Compile command to generate thrift model
@@ -62,16 +63,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
$bundlePath = $bundle->getPath();
//Set Path
- $compiler->setModelPath(sprintf('%s/ThriftModel', $bundlePath));
-
- // Empty old model
- $compiler->emptyModelPath($definition);
+ $compiler->setModelPath(sprintf('%s/%s', $bundlePath, ThriftCompileCacheWarmer::CACHE_SUFFIX));
//Add namespace prefix if needed
if($input->getOption('namespace'))
{
+ // Empty old model
+ $compiler->emptyModelPath($input->getOption('namespace'));
+
$compiler->setNamespacePrefix($input->getOption('namespace'));
}
+ else
+ {
+ // Empty old model
+ $compiler->emptyModelPath($definition);
+ }
$return = $compiler->compile($definitionPath, $input->getOption('server'));
View
8 Compiler/ThriftCompiler.php
@@ -105,12 +105,14 @@ public function setNamespacePrefix($namespace)
/**
* Empty model path
- * @param string $definition
+ * @param string $namespace
* @return boolean
*/
- public function emptyModelPath($definition)
+ public function emptyModelPath($namespace)
{
- $path = $this->modelPath . '/' . $definition;
+ $m = explode('\\', $namespace);
+
+ $path = $this->modelPath . '/' . $m[0];
// Check if model path exists
if(!is_null($path) && file_exists($path))
1 Fixtures/thrift
@@ -0,0 +1 @@
+Subproject commit fdaca075eec8e9e2ab9487d5fcffb635622138e3
View
4 Tests/Client/ThriftClientTest.php
@@ -28,6 +28,7 @@ protected function setUp()
$this->factory = new ThriftFactory(array(
'test' => array(
'definition' => 'Test',
+ 'className' => 'Test',
'namespace' => 'ThriftModel\Test'
)
));
@@ -49,6 +50,7 @@ public function testHttpClient()
),
'service_config' => array(
'definition' => 'Test',
+ 'className' => 'Test',
'namespace' => 'ThriftModel\Test',
'protocol' => 'Thrift\\Protocol\\TBinaryProtocolAccelerated'
)
@@ -83,6 +85,7 @@ protected function createSocketServer()
),
'service_config' => array(
'definition' => 'Test',
+ 'className' => 'Test',
'namespace' => 'ThriftModel\Test',
'protocol' => 'Thrift\\Protocol\\TBinaryProtocolAccelerated'
)
@@ -239,6 +242,7 @@ public function testMultiSocketClient()
),
'service_config' => array(
'definition' => 'Test',
+ 'className' => 'Test',
'namespace' => 'ThriftModel\Test',
'protocol' => 'Thrift\\Protocol\\TBinaryProtocolAccelerated'
)
View
4 Tests/Compiler/CompilerTest.php
@@ -21,7 +21,7 @@ public function testCompile()
$compiler->setModelPath($this->modelPath);
- $this->assertFalse($compiler->emptyModelPath('Test'), 'Return false because Definition directory does not exists');
+ $this->assertFalse($compiler->emptyModelPath('ThriftModel\Test'), 'Return false because Definition directory does not exists');
// Add namespace prefix
$compiler->setNamespacePrefix($this->namespace);
@@ -40,7 +40,7 @@ public function testCompile()
);
// Empty old model
- $this->assertTrue($compiler->emptyModelPath('Test'));
+ $this->assertTrue($compiler->emptyModelPath('Overblog\ThriftBundle\Tests'));
// Now compile with server
$this->assertTrue($compiler->compile($this->definitionPath, true), 'Return no error');
View
1 Tests/Factory/ThriftFactoryTest.php
@@ -22,6 +22,7 @@ public function testFactory()
$factory = new ThriftFactory(array(
'test' => array(
'definition' => 'Test',
+ 'className' => 'Test',
'namespace' => 'ThriftModel\Test'
)
));
View
4 Tests/ThriftBundleTestCase.php
@@ -13,7 +13,7 @@ class ThriftBundleTestCase extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->modelPath = __DIR__ . '/ThriftModel';
+ $this->modelPath = __DIR__ . '/thrift';
$this->definitionPath = __DIR__ . '/ThriftDefinition/Test.thrift';
}
@@ -22,7 +22,7 @@ protected function compile()
//Build cache
$this->compiler = new ThriftCompiler();
$this->compiler->setModelPath($this->modelPath);
- $this->compiler->emptyModelPath('Test');
+ $this->compiler->emptyModelPath('ThriftModel\Test');
$this->compiler->compile($this->definitionPath, true);
}
View
2 phpunit.xml.dist
@@ -11,7 +11,7 @@
bootstrap="./Tests/bootstrap.php">
<php>
<server name="SYMFONY" value="./Fixtures/symfony/src" />
- <server name="THRIFT" value="./Fixtures/thrift" />
+ <server name="THRIFT" value="./Fixtures/thrift/lib/phpsf2/src" />
</php>
<testsuites>
<testsuite name="OverblogThriftBundle Test Suite">

0 comments on commit d267bd2

Please sign in to comment.