Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude component vendor folder from snippet coverage #1168

Merged
merged 2 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Core/src/Testing/FileListFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

namespace Google\Cloud\Core\Testing;

use Google\Cloud\Dev\DocGenerator\RegexFileFilter;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


/**
* Filter to create a list of only required files
*
Expand Down Expand Up @@ -77,7 +79,7 @@ public function accept()
if ($exclude instanceof RegexFileFilter) {
$pattern = $exclude->regex;

if (preg_match('/'. $pattern .'/', $path) === 1) {
if (preg_match($pattern, $path) === 1) {
return false;
}

Expand Down
7 changes: 6 additions & 1 deletion Core/src/Testing/TestHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Google\Cloud\Core\Testing\Snippet\Coverage\Scanner;
use Google\Cloud\Core\Testing\Snippet\Parser\Parser;
use Google\Cloud\Core\Testing\System\SystemTestCase;
use Google\Cloud\Dev\DocGenerator\RegexFileFilter;

/**
* Class TestHelpers is used to hold static functions required for testing
Expand Down Expand Up @@ -109,7 +110,11 @@ public static function snippetBootstrap()
putenv('GOOGLE_APPLICATION_CREDENTIALS='. \Google\Cloud\Core\Testing\Snippet\Fixtures::KEYFILE_STUB_FIXTURE());

$parser = new Parser;
$scanner = new Scanner($parser, self::projectRoot(), ['/vendor/', '/dev/']);
$scanner = new Scanner($parser, self::projectRoot(), [
'/vendor/',
'/dev/',
new RegexFileFilter('/\w{0,}\/vendor\//')
]);
$coverage = new Coverage($scanner);
$coverage->buildListToCover();

Expand Down