From 708023c509c720e33bd889d06bd8a0b8c772aa01 Mon Sep 17 00:00:00 2001 From: bknutson Date: Mon, 6 May 2024 15:44:18 -0600 Subject: [PATCH 1/5] [SPEED-1380] Add new options for metric and symbol table output locations --- README.md | 38 ++++++++++++++++++++------------------ src/CommandLineRunner.php | 32 ++++++++++++++++++-------------- src/Config.php | 26 ++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index a1c15b8..f4a10e2 100644 --- a/README.md +++ b/README.md @@ -275,35 +275,37 @@ Note: Command line usage will probably change significantly in the v1.0 release.
 Usage: php -d memory_limit=500M vendor/bin/guardrail.php [-a] [-i] [-n #] [-o output_file_name] [-p #/#] config_file
 
-where: -p #/#                 = Define the number of partitions and the current partition.
-                                Use for multiple hosts. Example: -p 1/4
+where: -p #/#                               = Define the number of partitions and the current partition.
+                                              Use for multiple hosts. Example: -p 1/4
 
-       -n #                   = number of child process to run.
-                                Use for multiple processes on a single host.  A good rule of thumb is 1 process per CPU core.
+       -n #                                 = number of child process to run.
+                                              Use for multiple processes on a single host.  A good rule of thumb is 1 process per CPU core.
 
-       -a                     = run the "analyze" operation
+       -a                                   = run the "analyze" operation
 
-       -i                     = run the "index" operation.
-                                Defaults to yes if using in memory index.
+       -i                                   = run the "index" operation.
+                                              Defaults to yes if using in memory index.
                                 
-       --diff patch_file      = Allows you to limit results to only those errors occuring on
-                                lines in a particular patch set.  Requires unified diff format taken
-                                from the root directory of the project.  Must set emit { "when": "new" }
-                                for each error that you want to emit in this fashion.                                                                     
+       --diff patch_file                    = Allows you to limit results to only those errors occuring on
+                                              lines in a particular patch set.  Requires unified diff format taken
+                                              from the root directory of the project.  Must set emit { "when": "new" }
+                                              for each error that you want to emit in this fashion.                                                                     
                                 
-       --format format        = Select choose between "xunit", "text", or "counts"                                 
+       --format format                      = Select choose between "xunit", "text", or "counts"                                 
 
-       -s                     = prefer sqlite index
+       -s                                   = prefer sqlite index
 
-       -m                     = prefer in memory index (only available when -n=1 and -p=1/1)
+       -m                                   = prefer in memory index (only available when -n=1 and -p=1/1)
 
-       -o output_file_name    = Output results in junit format to the specified filename
-       
+       -o output_file_name                  = Output results in junit format to the specified filename
        
+       -mo metric_output_file_name          = Output results to the specified filename
+
+       -so symbol_table_output_file_name    = Output results to the specified filename
 
-       -v                     = Increase verbosity level.  Can be used once or twice.
+       -v                                   = Increase verbosity level.  Can be used once or twice.
 
-       -h  or --help          = Ignore all other options and show this page.
+       -h  or --help                        = Ignore all other options and show this page.
 
 
 
diff --git a/src/CommandLineRunner.php b/src/CommandLineRunner.php index fc95c07..18da1fd 100644 --- a/src/CommandLineRunner.php +++ b/src/CommandLineRunner.php @@ -25,32 +25,36 @@ public function usage() { echo " Usage: php guardrail.phar [-a] [-i] [-n #] [--format xunit|text] [-o output_file_name] [-p #/#] [--timings] config_file -where: -p #/# = Define the number of partitions and the current partition. +where: -p #/# = Define the number of partitions and the current partition. Use for multiple hosts. Example: -p 1/4 - --format {format} = Use \"xunit\" format or a more console friendly \"text\" format + --format {format} = Use \"xunit\" format or a more console friendly \"text\" format - -n # = number of child process to run. - Use for multiple processes on a single host. + -n # = number of child process to run. + Use for multiple processes on a single host. - -a = run the \"analyze\" operation + -a = run the \"analyze\" operation - -i = run the \"index\" operation. - Defaults to yes if using in memory index. + -i = run the \"index\" operation. + Defaults to yes if using in memory index. - -j = prefer json index + -j = prefer json index - -m = prefer in memory index (only available when -n=1 and -p=1/1) + -m = prefer in memory index (only available when -n=1 and -p=1/1) - -o output_file_name = Output results to the specified filename + -o output_file_name = Output results to the specified filename - -v = Increase verbosity level. Can be used once or twice. + -mo metric_output_file_name = Output results to the specified filename - -h or --help = Ignore all other options and show this page. + -so symbol_table_output_file_name = Output results to the specified filename + + -v = Increase verbosity level. Can be used once or twice. + + -h or --help = Ignore all other options and show this page. - -l or --list = Ignore all other options and list standard test names. + -l or --list = Ignore all other options and list standard test names. - --timings = Output a summary of how long each check ran for. + --timings = Output a summary of how long each check ran for. "; } diff --git a/src/Config.php b/src/Config.php index 0bdf79c..7b10070 100644 --- a/src/Config.php +++ b/src/Config.php @@ -39,7 +39,7 @@ class Config { protected $config = []; /** @var string */ - private $symbolTableFile = "symbol_table"; + private $symbolTableFile = "symbol_table.json"; /** @var int The number of partitions */ private $partitions = 1; @@ -52,6 +52,12 @@ class Config { /** @var string */ private $outputFile = ""; + /** @var string */ + private $metricOutputFile = ""; + + /** @var string */ + private $symbolTableOutputFile = ""; + /** @var int MEMORY_SYMBOL_TABLE | SQLITE_SYMBOL_TABLE */ private $preferredTable = self::MEMORY_SYMBOL_TABLE; @@ -353,6 +359,18 @@ private function parseArgv(array $argv) { } $this->outputFile = $argv[++$argCount]; break; + case '-mo': + if ($argCount + 1 >= count($argv)) { + throw new InvalidConfigException; + } + $this->metricOutputFile = $argv[++$argCount]; + break; + case '-so': + if ($argCount + 1 >= count($argv)) { + throw new InvalidConfigException; + } + $this->symbolTableOutputFile = $argv[++$argCount]; + break; case '--diff': if ($argCount + 1 >= count($argv)) { throw new InvalidConfigException(); @@ -502,6 +520,10 @@ public function getOutputFormat() { * @return string */ private function getSymbolTableFile() { + if (!empty($this->symbolTableOutputFile)) { + return $this->symbolTableOutputFile; + } + return $this->basePath . "/" . $this->symbolTableFile . ".json"; } @@ -551,6 +573,6 @@ public function getOutputFile() { } public function getMetricOutputFile() { - return "metrics.json"; + return $this->metricOutputFile ?: "metrics.json"; } } \ No newline at end of file From b5bf4d131b371d67ff7d04ce009a29d9b0848fd5 Mon Sep 17 00:00:00 2001 From: Ben Knutson <33047188+bknutson123@users.noreply.github.com> Date: Tue, 7 May 2024 10:45:15 -0600 Subject: [PATCH 2/5] Revert "[SPEED-1380] Add new options for metric and symbol table output locations" --- README.md | 38 ++++++++++++++++++-------------------- src/CommandLineRunner.php | 32 ++++++++++++++------------------ src/Config.php | 26 ++------------------------ 3 files changed, 34 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index f4a10e2..a1c15b8 100644 --- a/README.md +++ b/README.md @@ -275,37 +275,35 @@ Note: Command line usage will probably change significantly in the v1.0 release.
 Usage: php -d memory_limit=500M vendor/bin/guardrail.php [-a] [-i] [-n #] [-o output_file_name] [-p #/#] config_file
 
-where: -p #/#                               = Define the number of partitions and the current partition.
-                                              Use for multiple hosts. Example: -p 1/4
+where: -p #/#                 = Define the number of partitions and the current partition.
+                                Use for multiple hosts. Example: -p 1/4
 
-       -n #                                 = number of child process to run.
-                                              Use for multiple processes on a single host.  A good rule of thumb is 1 process per CPU core.
+       -n #                   = number of child process to run.
+                                Use for multiple processes on a single host.  A good rule of thumb is 1 process per CPU core.
 
-       -a                                   = run the "analyze" operation
+       -a                     = run the "analyze" operation
 
-       -i                                   = run the "index" operation.
-                                              Defaults to yes if using in memory index.
+       -i                     = run the "index" operation.
+                                Defaults to yes if using in memory index.
                                 
-       --diff patch_file                    = Allows you to limit results to only those errors occuring on
-                                              lines in a particular patch set.  Requires unified diff format taken
-                                              from the root directory of the project.  Must set emit { "when": "new" }
-                                              for each error that you want to emit in this fashion.                                                                     
+       --diff patch_file      = Allows you to limit results to only those errors occuring on
+                                lines in a particular patch set.  Requires unified diff format taken
+                                from the root directory of the project.  Must set emit { "when": "new" }
+                                for each error that you want to emit in this fashion.                                                                     
                                 
-       --format format                      = Select choose between "xunit", "text", or "counts"                                 
+       --format format        = Select choose between "xunit", "text", or "counts"                                 
 
-       -s                                   = prefer sqlite index
+       -s                     = prefer sqlite index
 
-       -m                                   = prefer in memory index (only available when -n=1 and -p=1/1)
+       -m                     = prefer in memory index (only available when -n=1 and -p=1/1)
 
-       -o output_file_name                  = Output results in junit format to the specified filename
+       -o output_file_name    = Output results in junit format to the specified filename
+       
        
-       -mo metric_output_file_name          = Output results to the specified filename
-
-       -so symbol_table_output_file_name    = Output results to the specified filename
 
-       -v                                   = Increase verbosity level.  Can be used once or twice.
+       -v                     = Increase verbosity level.  Can be used once or twice.
 
-       -h  or --help                        = Ignore all other options and show this page.
+       -h  or --help          = Ignore all other options and show this page.
 
 
 
diff --git a/src/CommandLineRunner.php b/src/CommandLineRunner.php index 18da1fd..fc95c07 100644 --- a/src/CommandLineRunner.php +++ b/src/CommandLineRunner.php @@ -25,36 +25,32 @@ public function usage() { echo " Usage: php guardrail.phar [-a] [-i] [-n #] [--format xunit|text] [-o output_file_name] [-p #/#] [--timings] config_file -where: -p #/# = Define the number of partitions and the current partition. +where: -p #/# = Define the number of partitions and the current partition. Use for multiple hosts. Example: -p 1/4 - --format {format} = Use \"xunit\" format or a more console friendly \"text\" format + --format {format} = Use \"xunit\" format or a more console friendly \"text\" format - -n # = number of child process to run. - Use for multiple processes on a single host. + -n # = number of child process to run. + Use for multiple processes on a single host. - -a = run the \"analyze\" operation + -a = run the \"analyze\" operation - -i = run the \"index\" operation. - Defaults to yes if using in memory index. + -i = run the \"index\" operation. + Defaults to yes if using in memory index. - -j = prefer json index + -j = prefer json index - -m = prefer in memory index (only available when -n=1 and -p=1/1) + -m = prefer in memory index (only available when -n=1 and -p=1/1) - -o output_file_name = Output results to the specified filename + -o output_file_name = Output results to the specified filename - -mo metric_output_file_name = Output results to the specified filename + -v = Increase verbosity level. Can be used once or twice. - -so symbol_table_output_file_name = Output results to the specified filename - - -v = Increase verbosity level. Can be used once or twice. - - -h or --help = Ignore all other options and show this page. + -h or --help = Ignore all other options and show this page. - -l or --list = Ignore all other options and list standard test names. + -l or --list = Ignore all other options and list standard test names. - --timings = Output a summary of how long each check ran for. + --timings = Output a summary of how long each check ran for. "; } diff --git a/src/Config.php b/src/Config.php index 7b10070..0bdf79c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -39,7 +39,7 @@ class Config { protected $config = []; /** @var string */ - private $symbolTableFile = "symbol_table.json"; + private $symbolTableFile = "symbol_table"; /** @var int The number of partitions */ private $partitions = 1; @@ -52,12 +52,6 @@ class Config { /** @var string */ private $outputFile = ""; - /** @var string */ - private $metricOutputFile = ""; - - /** @var string */ - private $symbolTableOutputFile = ""; - /** @var int MEMORY_SYMBOL_TABLE | SQLITE_SYMBOL_TABLE */ private $preferredTable = self::MEMORY_SYMBOL_TABLE; @@ -359,18 +353,6 @@ private function parseArgv(array $argv) { } $this->outputFile = $argv[++$argCount]; break; - case '-mo': - if ($argCount + 1 >= count($argv)) { - throw new InvalidConfigException; - } - $this->metricOutputFile = $argv[++$argCount]; - break; - case '-so': - if ($argCount + 1 >= count($argv)) { - throw new InvalidConfigException; - } - $this->symbolTableOutputFile = $argv[++$argCount]; - break; case '--diff': if ($argCount + 1 >= count($argv)) { throw new InvalidConfigException(); @@ -520,10 +502,6 @@ public function getOutputFormat() { * @return string */ private function getSymbolTableFile() { - if (!empty($this->symbolTableOutputFile)) { - return $this->symbolTableOutputFile; - } - return $this->basePath . "/" . $this->symbolTableFile . ".json"; } @@ -573,6 +551,6 @@ public function getOutputFile() { } public function getMetricOutputFile() { - return $this->metricOutputFile ?: "metrics.json"; + return "metrics.json"; } } \ No newline at end of file From ba5920c1ac12c329791973af88c6668504b0c71d Mon Sep 17 00:00:00 2001 From: Ben Knutson <33047188+bknutson123@users.noreply.github.com> Date: Tue, 7 May 2024 11:20:17 -0600 Subject: [PATCH 3/5] Revert "Revert "[SPEED-1380] Add new options for metric and symbol table output locations"" --- README.md | 38 ++++++++++++++++++++------------------ src/CommandLineRunner.php | 32 ++++++++++++++++++-------------- src/Config.php | 26 ++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index a1c15b8..f4a10e2 100644 --- a/README.md +++ b/README.md @@ -275,35 +275,37 @@ Note: Command line usage will probably change significantly in the v1.0 release.
 Usage: php -d memory_limit=500M vendor/bin/guardrail.php [-a] [-i] [-n #] [-o output_file_name] [-p #/#] config_file
 
-where: -p #/#                 = Define the number of partitions and the current partition.
-                                Use for multiple hosts. Example: -p 1/4
+where: -p #/#                               = Define the number of partitions and the current partition.
+                                              Use for multiple hosts. Example: -p 1/4
 
-       -n #                   = number of child process to run.
-                                Use for multiple processes on a single host.  A good rule of thumb is 1 process per CPU core.
+       -n #                                 = number of child process to run.
+                                              Use for multiple processes on a single host.  A good rule of thumb is 1 process per CPU core.
 
-       -a                     = run the "analyze" operation
+       -a                                   = run the "analyze" operation
 
-       -i                     = run the "index" operation.
-                                Defaults to yes if using in memory index.
+       -i                                   = run the "index" operation.
+                                              Defaults to yes if using in memory index.
                                 
-       --diff patch_file      = Allows you to limit results to only those errors occuring on
-                                lines in a particular patch set.  Requires unified diff format taken
-                                from the root directory of the project.  Must set emit { "when": "new" }
-                                for each error that you want to emit in this fashion.                                                                     
+       --diff patch_file                    = Allows you to limit results to only those errors occuring on
+                                              lines in a particular patch set.  Requires unified diff format taken
+                                              from the root directory of the project.  Must set emit { "when": "new" }
+                                              for each error that you want to emit in this fashion.                                                                     
                                 
-       --format format        = Select choose between "xunit", "text", or "counts"                                 
+       --format format                      = Select choose between "xunit", "text", or "counts"                                 
 
-       -s                     = prefer sqlite index
+       -s                                   = prefer sqlite index
 
-       -m                     = prefer in memory index (only available when -n=1 and -p=1/1)
+       -m                                   = prefer in memory index (only available when -n=1 and -p=1/1)
 
-       -o output_file_name    = Output results in junit format to the specified filename
-       
+       -o output_file_name                  = Output results in junit format to the specified filename
        
+       -mo metric_output_file_name          = Output results to the specified filename
+
+       -so symbol_table_output_file_name    = Output results to the specified filename
 
-       -v                     = Increase verbosity level.  Can be used once or twice.
+       -v                                   = Increase verbosity level.  Can be used once or twice.
 
-       -h  or --help          = Ignore all other options and show this page.
+       -h  or --help                        = Ignore all other options and show this page.
 
 
 
diff --git a/src/CommandLineRunner.php b/src/CommandLineRunner.php index fc95c07..18da1fd 100644 --- a/src/CommandLineRunner.php +++ b/src/CommandLineRunner.php @@ -25,32 +25,36 @@ public function usage() { echo " Usage: php guardrail.phar [-a] [-i] [-n #] [--format xunit|text] [-o output_file_name] [-p #/#] [--timings] config_file -where: -p #/# = Define the number of partitions and the current partition. +where: -p #/# = Define the number of partitions and the current partition. Use for multiple hosts. Example: -p 1/4 - --format {format} = Use \"xunit\" format or a more console friendly \"text\" format + --format {format} = Use \"xunit\" format or a more console friendly \"text\" format - -n # = number of child process to run. - Use for multiple processes on a single host. + -n # = number of child process to run. + Use for multiple processes on a single host. - -a = run the \"analyze\" operation + -a = run the \"analyze\" operation - -i = run the \"index\" operation. - Defaults to yes if using in memory index. + -i = run the \"index\" operation. + Defaults to yes if using in memory index. - -j = prefer json index + -j = prefer json index - -m = prefer in memory index (only available when -n=1 and -p=1/1) + -m = prefer in memory index (only available when -n=1 and -p=1/1) - -o output_file_name = Output results to the specified filename + -o output_file_name = Output results to the specified filename - -v = Increase verbosity level. Can be used once or twice. + -mo metric_output_file_name = Output results to the specified filename - -h or --help = Ignore all other options and show this page. + -so symbol_table_output_file_name = Output results to the specified filename + + -v = Increase verbosity level. Can be used once or twice. + + -h or --help = Ignore all other options and show this page. - -l or --list = Ignore all other options and list standard test names. + -l or --list = Ignore all other options and list standard test names. - --timings = Output a summary of how long each check ran for. + --timings = Output a summary of how long each check ran for. "; } diff --git a/src/Config.php b/src/Config.php index 0bdf79c..7b10070 100644 --- a/src/Config.php +++ b/src/Config.php @@ -39,7 +39,7 @@ class Config { protected $config = []; /** @var string */ - private $symbolTableFile = "symbol_table"; + private $symbolTableFile = "symbol_table.json"; /** @var int The number of partitions */ private $partitions = 1; @@ -52,6 +52,12 @@ class Config { /** @var string */ private $outputFile = ""; + /** @var string */ + private $metricOutputFile = ""; + + /** @var string */ + private $symbolTableOutputFile = ""; + /** @var int MEMORY_SYMBOL_TABLE | SQLITE_SYMBOL_TABLE */ private $preferredTable = self::MEMORY_SYMBOL_TABLE; @@ -353,6 +359,18 @@ private function parseArgv(array $argv) { } $this->outputFile = $argv[++$argCount]; break; + case '-mo': + if ($argCount + 1 >= count($argv)) { + throw new InvalidConfigException; + } + $this->metricOutputFile = $argv[++$argCount]; + break; + case '-so': + if ($argCount + 1 >= count($argv)) { + throw new InvalidConfigException; + } + $this->symbolTableOutputFile = $argv[++$argCount]; + break; case '--diff': if ($argCount + 1 >= count($argv)) { throw new InvalidConfigException(); @@ -502,6 +520,10 @@ public function getOutputFormat() { * @return string */ private function getSymbolTableFile() { + if (!empty($this->symbolTableOutputFile)) { + return $this->symbolTableOutputFile; + } + return $this->basePath . "/" . $this->symbolTableFile . ".json"; } @@ -551,6 +573,6 @@ public function getOutputFile() { } public function getMetricOutputFile() { - return "metrics.json"; + return $this->metricOutputFile ?: "metrics.json"; } } \ No newline at end of file From 4319dc26818cbed98c37985b2404611557f85e97 Mon Sep 17 00:00:00 2001 From: bknutson Date: Tue, 7 May 2024 11:21:01 -0600 Subject: [PATCH 4/5] update name --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index 7b10070..ed720fa 100644 --- a/src/Config.php +++ b/src/Config.php @@ -39,7 +39,7 @@ class Config { protected $config = []; /** @var string */ - private $symbolTableFile = "symbol_table.json"; + private $symbolTableFile = "symbol_table"; /** @var int The number of partitions */ private $partitions = 1; From c7c602364001f41c6fc7b245a86df33186e7d405 Mon Sep 17 00:00:00 2001 From: bknutson Date: Tue, 7 May 2024 14:46:33 -0600 Subject: [PATCH 5/5] update output file option names --- README.md | 4 ++-- src/CommandLineRunner.php | 4 ++-- src/Config.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f4a10e2..a60c1bd 100644 --- a/README.md +++ b/README.md @@ -299,9 +299,9 @@ where: -p #/# = Define the number of partitions an -o output_file_name = Output results in junit format to the specified filename - -mo metric_output_file_name = Output results to the specified filename + --metric-output = Output results to the specified filename - -so symbol_table_output_file_name = Output results to the specified filename + --symbol-table-output = Output results to the specified filename -v = Increase verbosity level. Can be used once or twice. diff --git a/src/CommandLineRunner.php b/src/CommandLineRunner.php index 18da1fd..cff0eec 100644 --- a/src/CommandLineRunner.php +++ b/src/CommandLineRunner.php @@ -44,9 +44,9 @@ public function usage() { -o output_file_name = Output results to the specified filename - -mo metric_output_file_name = Output results to the specified filename + --metric-output = Output results to the specified filename - -so symbol_table_output_file_name = Output results to the specified filename + --symbol-table-output = Output results to the specified filename -v = Increase verbosity level. Can be used once or twice. diff --git a/src/Config.php b/src/Config.php index ed720fa..f74bdb8 100644 --- a/src/Config.php +++ b/src/Config.php @@ -359,13 +359,13 @@ private function parseArgv(array $argv) { } $this->outputFile = $argv[++$argCount]; break; - case '-mo': + case '--metric-output': if ($argCount + 1 >= count($argv)) { throw new InvalidConfigException; } $this->metricOutputFile = $argv[++$argCount]; break; - case '-so': + case '--symbol-table-output': if ($argCount + 1 >= count($argv)) { throw new InvalidConfigException; }