Brian Wolff has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/391671 )
Change subject: Fix various tests
......................................................................
Fix various tests
Now phan, phpcs and custom integration tests can be run
via composer test
Change-Id: I3b82eeda0934fa1860fa88f2fe8918e01eb401cf
---
M .gitignore
M .phpcs.xml
M composer.json
M src/GenericSecurityCheckPlugin.php
M src/MediaWikiSecurityCheckPlugin.php
M src/SecurityCheckPlugin.php
D src/tests/integration/indirectecho3/.test.php.swp
D src/tests/integration/indirectecho3/expectedResults.txt
D src/tests/runtests.sh
C tests/general-phan-config.php
R tests/integration-test-config.php
R tests/integration/callwithevil/expectedResults.txt
R tests/integration/callwithevil/test.php
R tests/integration/callwithevil2/expectedResults.txt
R tests/integration/callwithevil2/test.php
R tests/integration/callwithevil3/expectedResults.txt
R tests/integration/callwithevil3/test.php
R tests/integration/echoevil/expectedResults.txt
R tests/integration/echoevil/test.php
R tests/integration/echoevil2/expectedResults.txt
R tests/integration/echoevil2/test.php
R tests/integration/echoevilfunc/expectedResults.txt
R tests/integration/echoevilfunc/test.php
R tests/integration/execvstaint/OutputPage.php
R tests/integration/execvstaint/expectedResults.txt
R tests/integration/execvstaint/test.php
R tests/integration/indirectecho/expectedResults.txt
R tests/integration/indirectecho/test.php
R tests/integration/indirectecho/test2.php
R tests/integration/indirectecho2/expectedResults.txt
R tests/integration/indirectecho2/test.php
A tests/integration/indirectecho3/expectedResults.txt
R tests/integration/indirectecho3/test.php
R tests/integration/miscpreserves/expectedResults.txt
R tests/integration/miscpreserves/test.php
R tests/integration/prop/expectedResults.txt
R tests/integration/prop/test.php
R tests/integration/refecho/expectedResults.txt
R tests/integration/refecho/reftest.php
R tests/integration/refescape/expectedResults.txt
R tests/integration/refescape/reftest.php
R tests/integration/refnoecho/expectedResults.txt
R tests/integration/refnoecho/reftest.php
R tests/integration/refviaparam/expectedResults.txt
R tests/integration/refviaparam/reftest.php
R tests/integration/refwrongesc/expectedResults.txt
R tests/integration/refwrongesc/reftest.php
R tests/integration/safebinop/expectedResults.txt
R tests/integration/safebinop/test.php
R tests/integration/safebinopor/expectedResults.txt
R tests/integration/safebinopor/test.php
R tests/integration/simpleecho/expectedResults.txt
R tests/integration/simpleecho/test.php
R tests/integration/staticprop/expectedResults.txt
R tests/integration/staticprop/test.php
R tests/integration/unsafebinop/expectedResults.txt
R tests/integration/unsafebinop/test.php
R tests/integration/viafunc/Html.php
R tests/integration/viafunc/OutputPage.php
R tests/integration/viafunc/expectedResults.txt
R tests/integration/viafunc/test.php
R tests/integration/viafuncbad/Html.php
R tests/integration/viafuncbad/OutputPage.php
R tests/integration/viafuncbad/expectedResults.txt
R tests/integration/viafuncbad/test.php
A tests/run-phan-on-plugin.sh
A tests/runtests.sh
67 files changed, 205 insertions(+), 33 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/tools/phan/SecurityCheckPlugin
refs/changes/71/391671/1
diff --git a/.gitignore b/.gitignore
index 3a9875b..6387907 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/vendor/
composer.lock
+.*\.swp
diff --git a/.phpcs.xml b/.phpcs.xml
index d10a2bf..b7513f7 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -13,16 +13,16 @@
<!-- Stuff we are only excluding in tests" -->
<rule ref="MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals">
- <exclude-pattern>./src/tests</exclude-pattern>
+ <exclude-pattern>./tests</exclude-pattern>
</rule>
<rule ref="Generic.Classes.DuplicateClassName.Found">
- <exclude-pattern>./src/tests</exclude-pattern>
+ <exclude-pattern>./tests</exclude-pattern>
</rule>
<rule
ref="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic">
- <exclude-pattern>./src/tests</exclude-pattern>
+ <exclude-pattern>./tests</exclude-pattern>
</rule>
<rule ref="MediaWiki.Files.ClassMatchesFilename.NotMatch">
- <exclude-pattern>./src/tests</exclude-pattern>
+ <exclude-pattern>./tests</exclude-pattern>
</rule>
</ruleset>
diff --git a/composer.json b/composer.json
index 6aa6840..9431ad0 100644
--- a/composer.json
+++ b/composer.json
@@ -11,8 +11,13 @@
},
"scripts": {
"test": [
- "phpcs -p -s"
+ "composer phpcs",
+ "composer integration-tests",
+ "composer phan-for-plugin"
],
+ "phpcs": "phpcs -p -s",
+ "integration-tests": "./tests/runtests.sh",
+ "phan-for-plugin": "./tests/run-phan-on-plugin.sh",
"fix": "phpcbf"
},
"license": "GPLv2",
diff --git a/src/GenericSecurityCheckPlugin.php
b/src/GenericSecurityCheckPlugin.php
index 2010605..51f9684 100644
--- a/src/GenericSecurityCheckPlugin.php
+++ b/src/GenericSecurityCheckPlugin.php
@@ -1,5 +1,5 @@
<?php
-require_once "SecurityCheckPlugin.php";
+require_once __DIR__ . "/SecurityCheckPlugin.php";
/**
* Copyright Brian Wolff 2017. Released under the GPL version 2 or later.
diff --git a/src/MediaWikiSecurityCheckPlugin.php
b/src/MediaWikiSecurityCheckPlugin.php
index da6bca4..bc6c4a4 100644
--- a/src/MediaWikiSecurityCheckPlugin.php
+++ b/src/MediaWikiSecurityCheckPlugin.php
@@ -2,7 +2,7 @@
/*
* Copyright Brian Wolff 2017. Released under the GPL version 2 or later.
*/
-require_once "SecurityCheckPlugin.php";
+require_once __DIR__ . "/SecurityCheckPlugin.php";
class MediaWikiSecurityCheckPlugin extends SecurityCheckPlugin {
diff --git a/src/SecurityCheckPlugin.php b/src/SecurityCheckPlugin.php
index f0156e0..0eb4490 100644
--- a/src/SecurityCheckPlugin.php
+++ b/src/SecurityCheckPlugin.php
@@ -1,8 +1,8 @@
<?php declare( strict_types=1 );
-require_once 'TaintednessBaseVisitor.php';
-require_once 'PreTaintednessVisitor.php';
-require_once 'TaintednessVisitor.php';
+require_once __DIR__ . '/TaintednessBaseVisitor.php';
+require_once __DIR__ . '/PreTaintednessVisitor.php';
+require_once __DIR__ . '/TaintednessVisitor.php';
use Phan\CodeBase;
use Phan\Language\Context;
diff --git a/src/tests/integration/indirectecho3/.test.php.swp
b/src/tests/integration/indirectecho3/.test.php.swp
deleted file mode 100644
index 4fde601..0000000
--- a/src/tests/integration/indirectecho3/.test.php.swp
+++ /dev/null
Binary files differ
diff --git a/src/tests/integration/indirectecho3/expectedResults.txt
b/src/tests/integration/indirectecho3/expectedResults.txt
deleted file mode 100644
index c214de8..0000000
--- a/src/tests/integration/indirectecho3/expectedResults.txt
+++ /dev/null
@@ -1 +0,0 @@
-integration/indirectecho2/test.php:5 SecurityCheckTaintedOutput Echoing
tainted expression (680) (Caused by: integration/indirectecho2/test.php +3)
diff --git a/src/tests/runtests.sh b/src/tests/runtests.sh
deleted file mode 100755
index bed7507..0000000
--- a/src/tests/runtests.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-testList=${1:-`ls integration`}
-tmpFile=`mktemp testtmp.XXXXXXXX`
-
-
-for i in $testList
-do
- echo "Running test $i"
- php7.0 /Users/bawolff/src/phan/phan \
- --project-root-directory "." \
- --config-file "config.php" \
- --output "php://stdout" \
- -l "integration/$i" | tee ${DEBUG:-/dev/null} | grep
SecurityCheckTaintedOutput > $tmpFile
- diff -u "integration/$i/expectedResults.txt" "$tmpFile"
-done
-rm $tmpFile
diff --git a/src/tests/config.php b/tests/general-phan-config.php
similarity index 63%
copy from src/tests/config.php
copy to tests/general-phan-config.php
index 16d8337..4f8c262 100644
--- a/src/tests/config.php
+++ b/tests/general-phan-config.php
@@ -1,5 +1,6 @@
<?php
+use \Phan\Config;
// If xdebug is enabled, we need to increase the nesting level for phan
ini_set( 'xdebug.max_nesting_level', 1000 );
@@ -45,6 +46,8 @@
* your application should be included in this list.
*/
'directory_list' => [
+ Config::projectPath( 'src' ),
+ Config::projectPath( 'vendor' )
],
/**
@@ -62,6 +65,7 @@
* files.
*/
"exclude_analysis_directory_list" => [
+ Config::projectPath( 'vendor' )
],
/**
@@ -144,7 +148,7 @@
* to a class property that wasn't explicitly
* defined.
*/
- 'allow_missing_properties' => false,
+ 'allow_missing_properties' => true,
/**
* Allow null to be cast as any type and for any
@@ -179,7 +183,7 @@
* `$class->$method()`) in ways that we're unable
* to make sense of.
*/
- 'dead_code_detection' => false,
+ 'dead_code_detection' => true,
/**
* If true, the dead code detection rig will
@@ -236,7 +240,7 @@
'expand_file_list' => false,
// Include a progress bar in the output
- 'progress_bar' => false,
+ 'progress_bar' => true,
/**
* The probability of actually emitting any progress
@@ -258,7 +262,56 @@
* to this black-list to inhibit them from being reported.
*/
'suppress_issue_types' => [
+ // 'PhanDeprecatedProperty',
],
+ /*'suppress_issue_types' => [
+ // approximate error count: 8
+ "PhanDeprecatedClass",
+ // approximate error count: 415
+ "PhanDeprecatedFunction",
+ // approximate error count: 25
+ "PhanDeprecatedProperty",
+ // approximate error count: 11
+ "PhanParamReqAfterOpt",
+ // approximate error count: 888
+ "PhanParamSignatureMismatch",
+ // approximate error count: 7
+ "PhanParamSignatureMismatchInternal",
+ // approximate error count: 125
+ "PhanParamTooMany",
+ // approximate error count: 3
+ "PhanParamTooManyInternal",
+ // approximate error count: 1
+ "PhanRedefineFunctionInternal",
+ // approximate error count: 2
+ "PhanTraitParentReference",
+ // approximate error count: 3
+ "PhanTypeComparisonFromArray",
+ // approximate error count: 3
+ "PhanTypeInvalidRightOperand",
+ // approximate error count: 218
+ "PhanTypeMismatchArgument",
+ // approximate error count: 13
+ "PhanTypeMismatchArgumentInternal",
+ // approximate error count: 14
+ "PhanTypeMismatchForeach",
+ // approximate error count: 56
+ "PhanTypeMismatchProperty",
+ // approximate error count: 74
+ "PhanTypeMismatchReturn",
+ // approximate error count: 11
+ "PhanTypeMissingReturn",
+ // approximate error count: 5
+ "PhanTypeNonVarPassByRef",
+ // approximate error count: 32
+ "PhanUndeclaredConstant",
+ // approximate error count: 233
+ "PhanUndeclaredMethod",
+ // approximate error count: 1224
+ "PhanUndeclaredProperty",
+ // approximate error count: 3
+ "PhanUndeclaredStaticMethod",
+ ],*/
/**
* If empty, no filter against issues types will be applied.
@@ -266,6 +319,91 @@
* will be emitted by Phan.
*/
'whitelist_issue_types' => [
+ // 'PhanAccessMethodPrivate',
+ // 'PhanAccessMethodProtected',
+ // 'PhanAccessNonStaticToStatic',
+ // 'PhanAccessPropertyPrivate',
+ // 'PhanAccessPropertyProtected',
+ // 'PhanAccessSignatureMismatch',
+ // 'PhanAccessSignatureMismatchInternal',
+ // 'PhanAccessStaticToNonStatic',
+ // 'PhanCompatibleExpressionPHP7',
+ // 'PhanCompatiblePHP7',
+ // 'PhanContextNotObject',
+ // 'PhanDeprecatedClass',
+ // 'PhanDeprecatedFunction',
+ // 'PhanDeprecatedProperty',
+ // 'PhanEmptyFile',
+ // 'PhanNonClassMethodCall',
+ // 'PhanNoopArray',
+ // 'PhanNoopClosure',
+ // 'PhanNoopConstant',
+ // 'PhanNoopProperty',
+ // 'PhanNoopVariable',
+ // 'PhanParamRedefined',
+ // 'PhanParamReqAfterOpt',
+ // 'PhanParamSignatureMismatch',
+ // 'PhanParamSignatureMismatchInternal',
+ // 'PhanParamSpecial1',
+ // 'PhanParamSpecial2',
+ // 'PhanParamSpecial3',
+ // 'PhanParamSpecial4',
+ // 'PhanParamTooFew',
+ // 'PhanParamTooFewInternal',
+ // 'PhanParamTooMany',
+ // 'PhanParamTooManyInternal',
+ // 'PhanParamTypeMismatch',
+ // 'PhanParentlessClass',
+ // 'PhanRedefineClass',
+ // 'PhanRedefineClassInternal',
+ // 'PhanRedefineFunction',
+ // 'PhanRedefineFunctionInternal',
+ // 'PhanStaticCallToNonStatic',
+ // 'PhanSyntaxError',
+ // 'PhanTraitParentReference',
+ // 'PhanTypeArrayOperator',
+ // 'PhanTypeArraySuspicious',
+ // 'PhanTypeComparisonFromArray',
+ // 'PhanTypeComparisonToArray',
+ // 'PhanTypeConversionFromArray',
+ // 'PhanTypeInstantiateAbstract',
+ // 'PhanTypeInstantiateInterface',
+ // 'PhanTypeInvalidLeftOperand',
+ // 'PhanTypeInvalidRightOperand',
+ // 'PhanTypeMismatchArgument',
+ // 'PhanTypeMismatchArgumentInternal',
+ // 'PhanTypeMismatchDefault',
+ // 'PhanTypeMismatchForeach',
+ // 'PhanTypeMismatchProperty',
+ // 'PhanTypeMismatchReturn',
+ // 'PhanTypeMissingReturn',
+ // 'PhanTypeNonVarPassByRef',
+ // 'PhanTypeParentConstructorCalled',
+ // 'PhanTypeVoidAssignment',
+ // 'PhanUnanalyzable',
+ // 'PhanUndeclaredClass',
+ // 'PhanUndeclaredClassCatch',
+ // 'PhanUndeclaredClassConstant',
+ // 'PhanUndeclaredClassInstanceof',
+ // 'PhanUndeclaredClassMethod',
+ // 'PhanUndeclaredClassReference',
+ // 'PhanUndeclaredConstant',
+ // 'PhanUndeclaredExtendedClass',
+ // 'PhanUndeclaredFunction',
+ // 'PhanUndeclaredInterface',
+ // 'PhanUndeclaredMethod',
+ // 'PhanUndeclaredProperty',
+ // 'PhanUndeclaredStaticMethod',
+ // 'PhanUndeclaredStaticProperty',
+ // 'PhanUndeclaredTrait',
+ // 'PhanUndeclaredTypeParameter',
+ // 'PhanUndeclaredTypeProperty',
+ // 'PhanUndeclaredVariable',
+ // 'PhanUnreferencedClass',
+ // 'PhanUnreferencedConstant',
+ // 'PhanUnreferencedMethod',
+ // 'PhanUnreferencedProperty',
+ // 'PhanVariableUseClause',
],
/**
@@ -274,6 +412,7 @@
* (E.g. ['_FOO' => '\\FooClass', 'page' => '\\PageClass', 'userId' =>
'int'])
*/
'globals_type_map' => [
+ // 'IP' => 'string',
],
// Emit issue messages with markdown formatting
@@ -287,7 +426,5 @@
// A list of plugin files to execute
'plugins' => [
- # '.phan/plugins/InlineTypePlugin.php',
- '../..//plugins/MediaWikiSecurityCheckPlugin.php',
],
];
diff --git a/src/tests/config.php b/tests/integration-test-config.php
similarity index 98%
rename from src/tests/config.php
rename to tests/integration-test-config.php
index 16d8337..a2b1b0a 100644
--- a/src/tests/config.php
+++ b/tests/integration-test-config.php
@@ -1,5 +1,6 @@
<?php
+use Phan\Config;
// If xdebug is enabled, we need to increase the nesting level for phan
ini_set( 'xdebug.max_nesting_level', 1000 );
@@ -287,7 +288,6 @@
// A list of plugin files to execute
'plugins' => [
- # '.phan/plugins/InlineTypePlugin.php',
- '../..//plugins/MediaWikiSecurityCheckPlugin.php',
+ Config::projectPath( '../src/MediaWikiSecurityCheckPlugin.php' )
],
];
diff --git a/src/tests/integration/callwithevil/expectedResults.txt
b/tests/integration/callwithevil/expectedResults.txt
similarity index 100%
rename from src/tests/integration/callwithevil/expectedResults.txt
rename to tests/integration/callwithevil/expectedResults.txt
diff --git a/src/tests/integration/callwithevil/test.php
b/tests/integration/callwithevil/test.php
similarity index 100%
rename from src/tests/integration/callwithevil/test.php
rename to tests/integration/callwithevil/test.php
diff --git a/src/tests/integration/callwithevil2/expectedResults.txt
b/tests/integration/callwithevil2/expectedResults.txt
similarity index 100%
rename from src/tests/integration/callwithevil2/expectedResults.txt
rename to tests/integration/callwithevil2/expectedResults.txt
diff --git a/src/tests/integration/callwithevil2/test.php
b/tests/integration/callwithevil2/test.php
similarity index 100%
rename from src/tests/integration/callwithevil2/test.php
rename to tests/integration/callwithevil2/test.php
diff --git a/src/tests/integration/callwithevil3/expectedResults.txt
b/tests/integration/callwithevil3/expectedResults.txt
similarity index 100%
rename from src/tests/integration/callwithevil3/expectedResults.txt
rename to tests/integration/callwithevil3/expectedResults.txt
diff --git a/src/tests/integration/callwithevil3/test.php
b/tests/integration/callwithevil3/test.php
similarity index 100%
rename from src/tests/integration/callwithevil3/test.php
rename to tests/integration/callwithevil3/test.php
diff --git a/src/tests/integration/echoevil/expectedResults.txt
b/tests/integration/echoevil/expectedResults.txt
similarity index 100%
rename from src/tests/integration/echoevil/expectedResults.txt
rename to tests/integration/echoevil/expectedResults.txt
diff --git a/src/tests/integration/echoevil/test.php
b/tests/integration/echoevil/test.php
similarity index 100%
rename from src/tests/integration/echoevil/test.php
rename to tests/integration/echoevil/test.php
diff --git a/src/tests/integration/echoevil2/expectedResults.txt
b/tests/integration/echoevil2/expectedResults.txt
similarity index 100%
rename from src/tests/integration/echoevil2/expectedResults.txt
rename to tests/integration/echoevil2/expectedResults.txt
diff --git a/src/tests/integration/echoevil2/test.php
b/tests/integration/echoevil2/test.php
similarity index 100%
rename from src/tests/integration/echoevil2/test.php
rename to tests/integration/echoevil2/test.php
diff --git a/src/tests/integration/echoevilfunc/expectedResults.txt
b/tests/integration/echoevilfunc/expectedResults.txt
similarity index 100%
rename from src/tests/integration/echoevilfunc/expectedResults.txt
rename to tests/integration/echoevilfunc/expectedResults.txt
diff --git a/src/tests/integration/echoevilfunc/test.php
b/tests/integration/echoevilfunc/test.php
similarity index 100%
rename from src/tests/integration/echoevilfunc/test.php
rename to tests/integration/echoevilfunc/test.php
diff --git a/src/tests/integration/execvstaint/OutputPage.php
b/tests/integration/execvstaint/OutputPage.php
similarity index 100%
rename from src/tests/integration/execvstaint/OutputPage.php
rename to tests/integration/execvstaint/OutputPage.php
diff --git a/src/tests/integration/execvstaint/expectedResults.txt
b/tests/integration/execvstaint/expectedResults.txt
similarity index 100%
rename from src/tests/integration/execvstaint/expectedResults.txt
rename to tests/integration/execvstaint/expectedResults.txt
diff --git a/src/tests/integration/execvstaint/test.php
b/tests/integration/execvstaint/test.php
similarity index 100%
rename from src/tests/integration/execvstaint/test.php
rename to tests/integration/execvstaint/test.php
diff --git a/src/tests/integration/indirectecho/expectedResults.txt
b/tests/integration/indirectecho/expectedResults.txt
similarity index 100%
rename from src/tests/integration/indirectecho/expectedResults.txt
rename to tests/integration/indirectecho/expectedResults.txt
diff --git a/src/tests/integration/indirectecho/test.php
b/tests/integration/indirectecho/test.php
similarity index 100%
rename from src/tests/integration/indirectecho/test.php
rename to tests/integration/indirectecho/test.php
diff --git a/src/tests/integration/indirectecho/test2.php
b/tests/integration/indirectecho/test2.php
similarity index 100%
rename from src/tests/integration/indirectecho/test2.php
rename to tests/integration/indirectecho/test2.php
diff --git a/src/tests/integration/indirectecho2/expectedResults.txt
b/tests/integration/indirectecho2/expectedResults.txt
similarity index 100%
rename from src/tests/integration/indirectecho2/expectedResults.txt
rename to tests/integration/indirectecho2/expectedResults.txt
diff --git a/src/tests/integration/indirectecho2/test.php
b/tests/integration/indirectecho2/test.php
similarity index 100%
rename from src/tests/integration/indirectecho2/test.php
rename to tests/integration/indirectecho2/test.php
diff --git a/tests/integration/indirectecho3/expectedResults.txt
b/tests/integration/indirectecho3/expectedResults.txt
new file mode 100644
index 0000000..b8342c8
--- /dev/null
+++ b/tests/integration/indirectecho3/expectedResults.txt
@@ -0,0 +1 @@
+integration/indirectecho3/test.php:7 SecurityCheckTaintedOutput Echoing
tainted expression (680) (Caused by: integration/indirectecho3/test.php +5)
diff --git a/src/tests/integration/indirectecho3/test.php
b/tests/integration/indirectecho3/test.php
similarity index 100%
rename from src/tests/integration/indirectecho3/test.php
rename to tests/integration/indirectecho3/test.php
diff --git a/src/tests/integration/miscpreserves/expectedResults.txt
b/tests/integration/miscpreserves/expectedResults.txt
similarity index 100%
rename from src/tests/integration/miscpreserves/expectedResults.txt
rename to tests/integration/miscpreserves/expectedResults.txt
diff --git a/src/tests/integration/miscpreserves/test.php
b/tests/integration/miscpreserves/test.php
similarity index 100%
rename from src/tests/integration/miscpreserves/test.php
rename to tests/integration/miscpreserves/test.php
diff --git a/src/tests/integration/prop/expectedResults.txt
b/tests/integration/prop/expectedResults.txt
similarity index 100%
rename from src/tests/integration/prop/expectedResults.txt
rename to tests/integration/prop/expectedResults.txt
diff --git a/src/tests/integration/prop/test.php
b/tests/integration/prop/test.php
similarity index 100%
rename from src/tests/integration/prop/test.php
rename to tests/integration/prop/test.php
diff --git a/src/tests/integration/refecho/expectedResults.txt
b/tests/integration/refecho/expectedResults.txt
similarity index 100%
rename from src/tests/integration/refecho/expectedResults.txt
rename to tests/integration/refecho/expectedResults.txt
diff --git a/src/tests/integration/refecho/reftest.php
b/tests/integration/refecho/reftest.php
similarity index 100%
rename from src/tests/integration/refecho/reftest.php
rename to tests/integration/refecho/reftest.php
diff --git a/src/tests/integration/refescape/expectedResults.txt
b/tests/integration/refescape/expectedResults.txt
similarity index 100%
rename from src/tests/integration/refescape/expectedResults.txt
rename to tests/integration/refescape/expectedResults.txt
diff --git a/src/tests/integration/refescape/reftest.php
b/tests/integration/refescape/reftest.php
similarity index 100%
rename from src/tests/integration/refescape/reftest.php
rename to tests/integration/refescape/reftest.php
diff --git a/src/tests/integration/refnoecho/expectedResults.txt
b/tests/integration/refnoecho/expectedResults.txt
similarity index 100%
rename from src/tests/integration/refnoecho/expectedResults.txt
rename to tests/integration/refnoecho/expectedResults.txt
diff --git a/src/tests/integration/refnoecho/reftest.php
b/tests/integration/refnoecho/reftest.php
similarity index 100%
rename from src/tests/integration/refnoecho/reftest.php
rename to tests/integration/refnoecho/reftest.php
diff --git a/src/tests/integration/refviaparam/expectedResults.txt
b/tests/integration/refviaparam/expectedResults.txt
similarity index 100%
rename from src/tests/integration/refviaparam/expectedResults.txt
rename to tests/integration/refviaparam/expectedResults.txt
diff --git a/src/tests/integration/refviaparam/reftest.php
b/tests/integration/refviaparam/reftest.php
similarity index 100%
rename from src/tests/integration/refviaparam/reftest.php
rename to tests/integration/refviaparam/reftest.php
diff --git a/src/tests/integration/refwrongesc/expectedResults.txt
b/tests/integration/refwrongesc/expectedResults.txt
similarity index 100%
rename from src/tests/integration/refwrongesc/expectedResults.txt
rename to tests/integration/refwrongesc/expectedResults.txt
diff --git a/src/tests/integration/refwrongesc/reftest.php
b/tests/integration/refwrongesc/reftest.php
similarity index 100%
rename from src/tests/integration/refwrongesc/reftest.php
rename to tests/integration/refwrongesc/reftest.php
diff --git a/src/tests/integration/safebinop/expectedResults.txt
b/tests/integration/safebinop/expectedResults.txt
similarity index 100%
rename from src/tests/integration/safebinop/expectedResults.txt
rename to tests/integration/safebinop/expectedResults.txt
diff --git a/src/tests/integration/safebinop/test.php
b/tests/integration/safebinop/test.php
similarity index 100%
rename from src/tests/integration/safebinop/test.php
rename to tests/integration/safebinop/test.php
diff --git a/src/tests/integration/safebinopor/expectedResults.txt
b/tests/integration/safebinopor/expectedResults.txt
similarity index 100%
rename from src/tests/integration/safebinopor/expectedResults.txt
rename to tests/integration/safebinopor/expectedResults.txt
diff --git a/src/tests/integration/safebinopor/test.php
b/tests/integration/safebinopor/test.php
similarity index 100%
rename from src/tests/integration/safebinopor/test.php
rename to tests/integration/safebinopor/test.php
diff --git a/src/tests/integration/simpleecho/expectedResults.txt
b/tests/integration/simpleecho/expectedResults.txt
similarity index 100%
rename from src/tests/integration/simpleecho/expectedResults.txt
rename to tests/integration/simpleecho/expectedResults.txt
diff --git a/src/tests/integration/simpleecho/test.php
b/tests/integration/simpleecho/test.php
similarity index 100%
rename from src/tests/integration/simpleecho/test.php
rename to tests/integration/simpleecho/test.php
diff --git a/src/tests/integration/staticprop/expectedResults.txt
b/tests/integration/staticprop/expectedResults.txt
similarity index 100%
rename from src/tests/integration/staticprop/expectedResults.txt
rename to tests/integration/staticprop/expectedResults.txt
diff --git a/src/tests/integration/staticprop/test.php
b/tests/integration/staticprop/test.php
similarity index 100%
rename from src/tests/integration/staticprop/test.php
rename to tests/integration/staticprop/test.php
diff --git a/src/tests/integration/unsafebinop/expectedResults.txt
b/tests/integration/unsafebinop/expectedResults.txt
similarity index 100%
rename from src/tests/integration/unsafebinop/expectedResults.txt
rename to tests/integration/unsafebinop/expectedResults.txt
diff --git a/src/tests/integration/unsafebinop/test.php
b/tests/integration/unsafebinop/test.php
similarity index 100%
rename from src/tests/integration/unsafebinop/test.php
rename to tests/integration/unsafebinop/test.php
diff --git a/src/tests/integration/viafunc/Html.php
b/tests/integration/viafunc/Html.php
similarity index 100%
rename from src/tests/integration/viafunc/Html.php
rename to tests/integration/viafunc/Html.php
diff --git a/src/tests/integration/viafunc/OutputPage.php
b/tests/integration/viafunc/OutputPage.php
similarity index 100%
rename from src/tests/integration/viafunc/OutputPage.php
rename to tests/integration/viafunc/OutputPage.php
diff --git a/src/tests/integration/viafunc/expectedResults.txt
b/tests/integration/viafunc/expectedResults.txt
similarity index 100%
rename from src/tests/integration/viafunc/expectedResults.txt
rename to tests/integration/viafunc/expectedResults.txt
diff --git a/src/tests/integration/viafunc/test.php
b/tests/integration/viafunc/test.php
similarity index 100%
rename from src/tests/integration/viafunc/test.php
rename to tests/integration/viafunc/test.php
diff --git a/src/tests/integration/viafuncbad/Html.php
b/tests/integration/viafuncbad/Html.php
similarity index 100%
rename from src/tests/integration/viafuncbad/Html.php
rename to tests/integration/viafuncbad/Html.php
diff --git a/src/tests/integration/viafuncbad/OutputPage.php
b/tests/integration/viafuncbad/OutputPage.php
similarity index 100%
rename from src/tests/integration/viafuncbad/OutputPage.php
rename to tests/integration/viafuncbad/OutputPage.php
diff --git a/src/tests/integration/viafuncbad/expectedResults.txt
b/tests/integration/viafuncbad/expectedResults.txt
similarity index 100%
rename from src/tests/integration/viafuncbad/expectedResults.txt
rename to tests/integration/viafuncbad/expectedResults.txt
diff --git a/src/tests/integration/viafuncbad/test.php
b/tests/integration/viafuncbad/test.php
similarity index 100%
rename from src/tests/integration/viafuncbad/test.php
rename to tests/integration/viafuncbad/test.php
diff --git a/tests/run-phan-on-plugin.sh b/tests/run-phan-on-plugin.sh
new file mode 100755
index 0000000..ea924a3
--- /dev/null
+++ b/tests/run-phan-on-plugin.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+dir=`dirname $0`
+cd "$dir/../"
+php7.0 "./vendor/etsy/phan/phan" \
+ --project-root-directory . \
+ --config-file "tests/general-phan-config.php" \
+ --output "php://stdout" \
+ "${@}"
+echo
diff --git a/tests/runtests.sh b/tests/runtests.sh
new file mode 100755
index 0000000..5a32398
--- /dev/null
+++ b/tests/runtests.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# If you want to see debug output
+# call with SECCHECK_DEBUG=/dev/stderr
+# environment variable.
+#
+# If you want to run a specific test
+# then give it as first arg.
+cd `dirname $0`/
+testList=${1:-`ls integration`}
+tmpFile=`mktemp testtmp.XXXXXXXX`
+totalTests=0
+failedTests=0
+php=`which php7.0`
+php=${php:-`which php`}
+
+for i in $testList
+do
+ echo "Running test $i"
+ totalTests=$((totalTests+1))
+ $php ../vendor/etsy/phan/phan \
+ --project-root-directory "." \
+ --config-file "integration-test-config.php" \
+ --output "php://stdout" \
+ -l "integration/$i" | grep SecurityCheckTaintedOutput >
$tmpFile
+ diff -u "integration/$i/expectedResults.txt" "$tmpFile"
+ if [ $? -gt 0 ]
+ then failedTests=$((failedTests+1))
+ fi
+done
+rm $tmpFile
+if [ $failedTests -gt 0 ]
+ then echo $failedTests out of $totalTests failed.
+ exit 1
+ else echo "All $totalTests passed."
+fi
--
To view, visit https://gerrit.wikimedia.org/r/391671
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b82eeda0934fa1860fa88f2fe8918e01eb401cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/phan/SecurityCheckPlugin
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits