From 3eadcc16b4f91e8deabcdd92ad8d4452eb893d2b Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Mon, 2 Mar 2020 16:42:38 -0600 Subject: [PATCH] MQE-1581: Remove NONE debug level for next MFTF major release --- dev/tests/_bootstrap.php | 2 +- docs/commands/mftf.md | 8 ++++---- .../Config/MftfApplicationConfig.php | 16 +++++++++------- .../Config/Reader/Filesystem.php | 3 ++- .../Config/Reader/MftfFilesystem.php | 4 ++-- .../Console/BaseGenerateCommand.php | 3 +-- .../Console/GenerateDocsCommand.php | 2 +- .../Console/GenerateTestsCommand.php | 3 +-- .../StaticCheck/ActionGroupArgumentsCheck.php | 2 +- .../StaticCheck/TestDependencyCheck.php | 2 +- 10 files changed, 23 insertions(+), 22 deletions(-) diff --git a/dev/tests/_bootstrap.php b/dev/tests/_bootstrap.php index 3f57ad139..26582ff3d 100644 --- a/dev/tests/_bootstrap.php +++ b/dev/tests/_bootstrap.php @@ -35,7 +35,7 @@ true, \Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::UNIT_TEST_PHASE, true, - \Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::LEVEL_NONE, + \Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::LEVEL_DEFAULT, false ); diff --git a/docs/commands/mftf.md b/docs/commands/mftf.md index e0394dc12..297addc6b 100644 --- a/docs/commands/mftf.md +++ b/docs/commands/mftf.md @@ -164,7 +164,7 @@ vendor/bin/mftf generate:tests [option] [] [] [--remove] | `-i,--time` | Set time in minutes to determine the group size when `--config=parallel` is used. The __default value__ is `10`. Example: `generate:tests --config=parallel --time=15`| | `--tests` | Defines the test configuration as a JSON string.| | `--allow-skipped` | Allows MFTF to generate and run tests marked with `.`| -| `--debug or --debug=[]`| Performs schema validations on XML files.
DEFAULT: `generate:tests` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered.
DEVELOPER: `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred) when test generation fails because of an invalid XML schema. This option takes extra processing time. Use it after test generation has failed once.
NONE: `--debug=none` skips debugging during test generation. Added for backward compatibility, it will be removed in the next MAJOR release.
| +| `--debug` | Performs schema validations on XML files.
DEFAULT: `generate:tests` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered.
DEVELOPER: `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred) when test generation fails because of an invalid XML schema. This option takes extra processing time. Use it after test generation has failed once.
| | `-r,--remove`| Removes the existing generated suites and tests cleaning up the `_generated` directory before the actual run. For example, `generate:tests SampleTest --remove` cleans up the entire `_generated` directory and generates `SampleTest` only.| #### Examples of the JSON configuration @@ -337,7 +337,7 @@ vendor/bin/mftf run:group [--skip-generate|--remove] [--] [] | --------------------- | --------------------------------------------------------------------------------------------------------- | | `-k, --skip-generate` | Skips generating from the source XML. Instead, the command executes previously-generated groups of tests. | | `-r, --remove` | Removes previously generated suites and tests before the actual generation and run. | -| `--debug or --debug=[]`| Performs schema validations on XML files. `run:group` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.| +| `--debug` | Performs schema validations on XML files. `run:group` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred).| #### Examples @@ -369,7 +369,7 @@ vendor/bin/mftf run:test [--skip-generate|--remove] [--] [] |-----------------------|-----------------------------------------------------------------------------------------------------------| | `-k, --skip-generate` | Skips generating from the source XML. Instead, the command executes previously-generated groups of tests. | | `-r, --remove` | Remove previously generated suites and tests. | -| `--debug or --debug=[]`| Performs schema validations on XML files. `run:test` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release. +| `--debug` | Performs schema validations on XML files. `run:test` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred).| #### Examples @@ -419,7 +419,7 @@ vendor/bin/mftf run:failed | Option | Description | |-----------------------|-----------------------------------------------------------------------------------------------------------| -| `--debug or --debug=[]`| Performs schema validations on XML files. `run:failed` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). Use it after test run has failed once. `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.| +| `--debug` | Performs schema validations on XML files. `run:failed` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). Use it after test run has failed once.| #### Examples diff --git a/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php b/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php index 4b215cb4f..ab06b5612 100644 --- a/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php +++ b/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php @@ -23,8 +23,7 @@ class MftfApplicationConfig */ const LEVEL_DEFAULT = "default"; const LEVEL_DEVELOPER = "developer"; - const LEVEL_NONE = "none"; - const MFTF_DEBUG_LEVEL = [self::LEVEL_DEFAULT, self::LEVEL_DEVELOPER, self::LEVEL_NONE]; + const MFTF_DEBUG_LEVEL = [self::LEVEL_DEFAULT, self::LEVEL_DEVELOPER]; /** * Contains object with test filters. @@ -89,7 +88,7 @@ private function __construct( $forceGenerate = false, $phase = self::EXECUTION_PHASE, $verboseEnabled = null, - $debugLevel = self::LEVEL_NONE, + $debugLevel = self::LEVEL_DEFAULT, $allowSkipped = false, $filters = [] ) { @@ -101,14 +100,17 @@ private function __construct( $this->phase = $phase; $this->verboseEnabled = $verboseEnabled; - switch ($debugLevel) { + if (isset($debugLevel) && !in_array(strtolower($debugLevel), self::MFTF_DEBUG_LEVEL)) { + throw new TestFrameworkException("{$debugLevel} is not a debug level. Use 'DEFAULT' or 'DEVELOPER'"); + } + switch (strtolower($debugLevel)) { case self::LEVEL_DEVELOPER: case self::LEVEL_DEFAULT: - case self::LEVEL_NONE: $this->debugLevel = $debugLevel; break; - default: + case null: $this->debugLevel = self::LEVEL_DEVELOPER; + break; } $this->allowSkipped = $allowSkipped; $this->filterList = new FilterList($filters); @@ -131,7 +133,7 @@ public static function create( $forceGenerate = false, $phase = self::EXECUTION_PHASE, $verboseEnabled = null, - $debugLevel = self::LEVEL_NONE, + $debugLevel = self::LEVEL_DEFAULT, $allowSkipped = false, $filters = [] ) { diff --git a/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php b/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php index db96b010c..ab7d64ea9 100644 --- a/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php +++ b/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php @@ -146,6 +146,7 @@ protected function readFiles($fileList) { /** @var \Magento\FunctionalTestingFramework\Config\Dom $configMerger */ $configMerger = null; + $debugLevel = MftfApplicationConfig::getConfig()->getDebugLevel(); foreach ($fileList as $key => $content) { //check if file is empty and continue to next if it is if (!$this->verifyFileEmpty($content, $fileList->getFilename())) { @@ -157,7 +158,7 @@ protected function readFiles($fileList) } else { $configMerger->merge($content); } - if (MftfApplicationConfig::getConfig()->getDebugLevel() === MftfApplicationConfig::LEVEL_DEVELOPER) { + if (strcasecmp($debugLevel, MftfApplicationConfig::LEVEL_DEVELOPER) == 0) { $this->validateSchema($configMerger, $fileList->getFilename()); } } catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) { diff --git a/src/Magento/FunctionalTestingFramework/Config/Reader/MftfFilesystem.php b/src/Magento/FunctionalTestingFramework/Config/Reader/MftfFilesystem.php index cd075e57c..3740d683f 100644 --- a/src/Magento/FunctionalTestingFramework/Config/Reader/MftfFilesystem.php +++ b/src/Magento/FunctionalTestingFramework/Config/Reader/MftfFilesystem.php @@ -42,7 +42,7 @@ public function readFiles($fileList) $configMerger->merge($content, $fileList->getFilename(), $exceptionCollector); } // run per file validation with generate:tests -d - if ($debugLevel === MftfApplicationConfig::LEVEL_DEVELOPER) { + if (strcasecmp($debugLevel, MftfApplicationConfig::LEVEL_DEVELOPER) == 0) { $this->validateSchema($configMerger, $fileList->getFilename()); } } catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) { @@ -52,7 +52,7 @@ public function readFiles($fileList) $exceptionCollector->throwException(); //run validation on merged file with generate:tests - if ($debugLevel === MftfApplicationConfig::LEVEL_DEFAULT) { + if (strcasecmp($debugLevel, MftfApplicationConfig::LEVEL_DEFAULT) == 0) { $this->validateSchema($configMerger); } diff --git a/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php index 9bcc27c86..07597acc5 100644 --- a/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php @@ -58,8 +58,7 @@ protected function configure() 'debug', 'd', InputOption::VALUE_OPTIONAL, - 'Run extra validation when generating and running tests. Use option \'none\' to turn off debugging -- - added for backward compatibility, will be removed in the next MAJOR release', + 'Run extra validation when generating and running tests.', MftfApplicationConfig::LEVEL_DEFAULT ); } diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php index 7def3894f..ce920e39d 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $force, MftfApplicationConfig::GENERATION_PHASE, false, - MftfApplicationConfig::LEVEL_NONE, + MftfApplicationConfig::LEVEL_DEFAULT, true ); diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php index 25bd68240..49ed8c6e1 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php @@ -123,8 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // Remove previous GENERATED_DIR if --remove option is used if ($remove) { - $this->removeGeneratedDirectory($output, $verbose || - ($debug !== MftfApplicationConfig::LEVEL_NONE)); + $this->removeGeneratedDirectory($output, $verbose); } try { diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php index 32c7661fe..ad0f8267d 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php @@ -54,7 +54,7 @@ public function execute(InputInterface $input) true, MftfApplicationConfig::UNIT_TEST_PHASE, false, - MftfApplicationConfig::LEVEL_NONE, + MftfApplicationConfig::LEVEL_DEFAULT, true ); diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php index 3c3ed6a37..e53c07573 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php @@ -96,7 +96,7 @@ public function execute(InputInterface $input) true, MftfApplicationConfig::UNIT_TEST_PHASE, false, - MftfApplicationConfig::LEVEL_NONE, + MftfApplicationConfig::LEVEL_DEFAULT, true );