summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Sippola <juhasippola@outlook.com>2015-08-05 10:53:08 +0300
committerTony Sarajärvi <tony.sarajarvi@theqtcompany.com>2015-09-16 07:34:20 +0000
commit4296e134c0dab7a37e23a86f57afd5f4cdcb4583 (patch)
treeb2d0b04601fb37f56d8ee3cf7ddac8d1c9a9ab60
parent01bd38e4a7bf00e993a4ede53c47cb7de2c75e0e (diff)
Qt Metrics 2: Log link
Added function to get the log file link for ProjectRun and ConfRun classes. The link path is in the ini file. Change-Id: Ia1ebc4b124b1eedb9d3411c1d69a3a5496ca2efa Reviewed-by: Tony Sarajärvi <tony.sarajarvi@theqtcompany.com>
-rw-r--r--non-puppet/qtmetrics2/src/ConfRun.php17
-rw-r--r--non-puppet/qtmetrics2/src/Factory.php10
-rw-r--r--non-puppet/qtmetrics2/src/ProjectRun.php32
-rw-r--r--non-puppet/qtmetrics2/src/test/FactoryTest.php16
4 files changed, 73 insertions, 2 deletions
diff --git a/non-puppet/qtmetrics2/src/ConfRun.php b/non-puppet/qtmetrics2/src/ConfRun.php
index 80089f4..9598e6c 100644
--- a/non-puppet/qtmetrics2/src/ConfRun.php
+++ b/non-puppet/qtmetrics2/src/ConfRun.php
@@ -34,8 +34,8 @@
/**
* ConfRun class
- * @version 0.1
- * @since 30-06-2015
+ * @version 0.2
+ * @since 24-07-2015
* @author Juha Sippola
*/
@@ -116,6 +116,19 @@ class ConfRun extends ProjectRun {
return $this->insignificant;
}
+ /**
+ * Get log file link.
+ * @return string
+ */
+ public function getLogLink()
+ {
+ return Factory::getCiLogPath()
+ . urlencode(parent::getFullProjectName())
+ . '/build_' . parent::getBuildKeyString()
+ . '/' . urlencode($this->name)
+ . '/log.txt.gz';
+ }
+
}
?>
diff --git a/non-puppet/qtmetrics2/src/Factory.php b/non-puppet/qtmetrics2/src/Factory.php
index f39796e..754168c 100644
--- a/non-puppet/qtmetrics2/src/Factory.php
+++ b/non-puppet/qtmetrics2/src/Factory.php
@@ -116,6 +116,16 @@ class Factory {
}
/**
+ * Get the CI log path.
+ * @return string
+ */
+ public static function getCiLogPath()
+ {
+ $ini = self::conf();
+ return $ini['ci_log_path'];
+ }
+
+ /**
* Check if the testset exists in the database
* @param string $name
* @return boolean
diff --git a/non-puppet/qtmetrics2/src/ProjectRun.php b/non-puppet/qtmetrics2/src/ProjectRun.php
index 26fb995..4e5a9ad 100644
--- a/non-puppet/qtmetrics2/src/ProjectRun.php
+++ b/non-puppet/qtmetrics2/src/ProjectRun.php
@@ -186,6 +186,38 @@ class ProjectRun {
return $this->duration;
}
+ /**
+ * Convert the numeric build key to a five digit string needed for directory links (e.g. 123 to 00123)
+ * @return string
+ */
+ public function getBuildKeyString()
+ {
+ $buildString = $this->buildKey;
+ if (is_numeric($buildString)) {
+ if ($this->buildKey < 10000)
+ $buildString = '0' . $this->buildKey;
+ if ($this->buildKey < 1000)
+ $buildString = '00' . $this->buildKey;
+ if ($this->buildKey < 100)
+ $buildString = '000' . $this->buildKey;
+ if ($this->buildKey < 10)
+ $buildString = '0000' . $this->buildKey;
+ }
+ return $buildString;
+ }
+
+ /**
+ * Get log file link.
+ * @return string
+ */
+ public function getLogLink()
+ {
+ return Factory::getCiLogPath()
+ . urlencode(self::getFullProjectName())
+ . '/build_' . self::getBuildKeyString()
+ . '/log.txt.gz';
+ }
+
}
?>
diff --git a/non-puppet/qtmetrics2/src/test/FactoryTest.php b/non-puppet/qtmetrics2/src/test/FactoryTest.php
index d53fd60..126702b 100644
--- a/non-puppet/qtmetrics2/src/test/FactoryTest.php
+++ b/non-puppet/qtmetrics2/src/test/FactoryTest.php
@@ -79,6 +79,22 @@ class FactoryTest extends PHPUnit_Framework_TestCase
}
/**
+ * Test getCiLogPath
+ * @dataProvider testGetCiLogPathData
+ */
+ public function testGetCiLogPath($exp_path)
+ {
+ $path = Factory::getCiLogPath();
+ $this->assertEquals($exp_path, $path);
+ }
+ public function testGetCiLogPathData()
+ {
+ return array(
+ array('http://testresults.qt.io/ci/')
+ );
+ }
+
+ /**
* Test checkTestset
* @dataProvider testCheckTestsetData
*/