Skip to content

Commit

Permalink
Restructure testing (#929)
Browse files Browse the repository at this point in the history
* Add system test credentials CLI

* Update Snippet testing for restructure

* Fix unit tests for restructure

* Fix system test runner

* Fix conformance bootstrap

* fix credentials CLIts

* Fix docs

* exclude dev folder from snippet parsing

* install latest composer

* Credentials CLI should not throw exception

* Test component integration

* Don't fail if extension is missing

* skip tests if debugger ext is missing

* Allow setting the search location paths for the SourceLocationResolver (#6)
  • Loading branch information
jdpedrie authored and dwsupplee committed Mar 22, 2018
1 parent d72266f commit 06f02c5
Show file tree
Hide file tree
Showing 181 changed files with 1,005 additions and 1,709 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ vendor/

# do not delete
keys/
.testing
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ before_script:
- if [[ $TRAVIS_PHP_VERSION =~ ^7 ]]; then pecl install stackdriver_debugger-alpha || echo 'Failed to install stackdriver_debugger'; fi
- composer install
- if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then composer --no-interaction --dev remove google/protobuf google/gax google/proto-client; fi
- ./dev/sh/system-test-credentials
- dev/google-cloud credentials

env:
global:
Expand All @@ -34,7 +34,3 @@ after_success:
- if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then bash <(curl -s https://codecov.io/bash); fi
- ./dev/sh/push-docs
- ./dev/sh/trigger-split
- cat ./build/snippets-uncovered.json

after_failure:
- echo "SNIPPET COVERAGE REPORT" && cat ./build/snippets-uncovered.json
5 changes: 4 additions & 1 deletion BigQuery/phpunit-snippets.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Snippet/bootstrap.php" colors="true">
<phpunit
bootstrap="./vendor/google/cloud-core/snippet-bootstrap.php"
colors="true"
printerClass="Google\Cloud\Core\Testing\Snippet\Coverage\ResultPrinter">
<testsuites>
<testsuite>
<directory>tests/Snippet</directory>
Expand Down
2 changes: 1 addition & 1 deletion BigQuery/phpunit-system.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/System/bootstrap.php" colors="true">
<phpunit bootstrap="./vendor/google-cloud/cloud-core/system-bootstrap.php" colors="true">
<testsuites>
<testsuite>
<directory>tests/System</directory>
Expand Down
2 changes: 1 addition & 1 deletion BigQuery/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Unit/bootstrap.php" colors="true">
<phpunit colors="true">
<testsuites>
<testsuite>
<directory>tests/Unit</directory>
Expand Down
43 changes: 0 additions & 43 deletions BigQuery/tests/Snippet/bootstrap.php

This file was deleted.

23 changes: 2 additions & 21 deletions BigQuery/tests/System/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
<?php

require __DIR__ . '/../../vendor/autoload.php';
use Google\Cloud\Core\Testing\TestHelpers;

use Google\Cloud\Core\Testing\System\SystemTestCase;

if (!getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH')) {
throw new \Exception(
'Please set the \'GOOGLE_CLOUD_PHP_TESTS_KEY_PATH\' env var to run the system tests'
);
}

SystemTestCase::setupQueue();

$pid = getmypid();
register_shutdown_function(function () use ($pid) {
// Skip flushing deletion queue if exiting a forked process.
if ($pid !== getmypid()) {
return;
}

// This should always be last.
SystemTestCase::processQueue();
});
TestHelpers::requireKeyfile('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
3 changes: 0 additions & 3 deletions BigQuery/tests/Unit/bootstrap.php

This file was deleted.

4 changes: 3 additions & 1 deletion Bigtable/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"google/gax": "^0.30"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0"
"phpunit/phpunit": "^4.8|^5.0",
"google/cloud-core": "^1.14",
"phpdocumentor/reflection": "^3.0"
},
"suggest": {
"ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions."
Expand Down
5 changes: 4 additions & 1 deletion Bigtable/phpunit-snippets.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Snippet/bootstrap.php" colors="true">
<phpunit
bootstrap="./vendor/google/cloud-core/snippet-bootstrap.php"
colors="true"
printerClass="Google\Cloud\Core\Testing\Snippet\Coverage\ResultPrinter">
<testsuites>
<testsuite>
<directory>tests/Snippet</directory>
Expand Down
2 changes: 1 addition & 1 deletion Bigtable/phpunit-system.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/System/bootstrap.php" colors="true">
<phpunit bootstrap="./vendor/google-cloud/cloud-core/system-bootstrap.php" colors="true">
<testsuites>
<testsuite>
<directory>tests/System</directory>
Expand Down
2 changes: 1 addition & 1 deletion Bigtable/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Unit/bootstrap.php" colors="true">
<phpunit colors="true">
<testsuites>
<testsuite>
<directory>tests/Unit</directory>
Expand Down
43 changes: 0 additions & 43 deletions Bigtable/tests/Snippet/bootstrap.php

This file was deleted.

8 changes: 2 additions & 6 deletions Bigtable/tests/System/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php

require __DIR__ . '/../../vendor/autoload.php';
use Google\Cloud\Core\Testing\TestHelpers;

if (!getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH')) {
throw new \Exception(
'Please set the \'GOOGLE_CLOUD_PHP_TESTS_KEY_PATH\' env var to run the system tests'
);
}
TestHelpers::requireKeyfile('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
3 changes: 0 additions & 3 deletions Bigtable/tests/Unit/bootstrap.php

This file was deleted.

4 changes: 3 additions & 1 deletion Container/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"google/gax": "^0.30"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0"
"phpunit/phpunit": "^4.8|^5.0",
"google/cloud-core": "^1.14",
"phpdocumentor/reflection": "^3.0"
}
}
5 changes: 4 additions & 1 deletion Container/phpunit-snippets.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Snippet/bootstrap.php" colors="true">
<phpunit
bootstrap="./vendor/google/cloud-core/snippet-bootstrap.php"
colors="true"
printerClass="Google\Cloud\Core\Testing\Snippet\Coverage\ResultPrinter">
<testsuites>
<testsuite>
<directory>tests/Snippet</directory>
Expand Down
2 changes: 1 addition & 1 deletion Container/phpunit-system.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/System/bootstrap.php" colors="true">
<phpunit bootstrap="./vendor/google-cloud/cloud-core/system-bootstrap.php" colors="true">
<testsuites>
<testsuite>
<directory>tests/System</directory>
Expand Down
2 changes: 1 addition & 1 deletion Container/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Unit/bootstrap.php" colors="true">
<phpunit colors="true">
<testsuites>
<testsuite>
<directory>tests/Unit</directory>
Expand Down
43 changes: 0 additions & 43 deletions Container/tests/Snippet/bootstrap.php

This file was deleted.

8 changes: 2 additions & 6 deletions Container/tests/System/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php

require __DIR__ . '/../../vendor/autoload.php';
use Google\Cloud\Core\Testing\TestHelpers;

if (!getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH')) {
throw new \Exception(
'Please set the \'GOOGLE_CLOUD_PHP_TESTS_KEY_PATH\' env var to run the system tests'
);
}
TestHelpers::requireKeyfile('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
3 changes: 0 additions & 3 deletions Container/tests/Unit/bootstrap.php

This file was deleted.

5 changes: 4 additions & 1 deletion Core/phpunit-snippets.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Snippet/bootstrap.php" colors="true">
<phpunit
bootstrap="./snippet-bootstrap.php"
colors="true"
printerClass="Google\Cloud\Core\Testing\Snippet\Coverage\ResultPrinter">
<testsuites>
<testsuite>
<directory>tests/Snippet</directory>
Expand Down
2 changes: 1 addition & 1 deletion Core/phpunit-system.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/System/bootstrap.php" colors="true">
<phpunit bootstrap="./vendor/google-cloud/cloud-core/system-bootstrap.php" colors="true">
<testsuites>
<testsuite>
<directory>tests/System</directory>
Expand Down
2 changes: 1 addition & 1 deletion Core/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/Unit/bootstrap.php" colors="true">
<phpunit colors="true">
<testsuites>
<testsuite>
<directory>tests/Unit</directory>
Expand Down
5 changes: 5 additions & 0 deletions Core/snippet-bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

use Google\Cloud\Core\Testing\TestHelpers;

TestHelpers::snippetBootstrap();
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
* limitations under the License.
*/

namespace Google\Cloud\Dev\DocGenerator;
namespace Google\Cloud\Core\Testing;

/**
* Filter to create a list of only required files
*
* @experimental
* @internal
*/
class FileListFilterIterator extends \FilterIterator
{
Expand All @@ -27,6 +30,15 @@ class FileListFilterIterator extends \FilterIterator
private $testPaths = [];
private $excludes = [];

/**
* @param string $projectRootPath The path to the root of the project.
* @param \Iterator $iterator The iterator to find files.
* @param array $fileTypes A list of file types to include
* @param array $testPaths A list of known patterns for test files.
* @param array $excludes A list of patterns to exclude from the result.
* @experimental
* @internal
*/
public function __construct(
$projectRootPath,
\Iterator $iterator,
Expand All @@ -42,6 +54,14 @@ public function __construct(
parent::__construct($iterator);
}

/**
* Decides whether to include the file or exclude it.
*
* @return bool
*
* @experimental
* @internal
*/
public function accept()
{
/** @var \SplFileInfo */
Expand Down
Loading

0 comments on commit 06f02c5

Please sign in to comment.