jenkins-bot has submitted this change and it was merged. Change subject: make-release: initial tarball test script ......................................................................
make-release: initial tarball test script Initial tarball test script. It is currently testing tarball extraction, $wgVersion and the commandline installer. Prerequisites: - A MediaWiki tarball in the folder you execute the script from - SQLlite database - Write permissions in the folder you execute the script from - Phpunit installed and PHPUnit_* classes accessible by php Usage: phpunit [switches] testReleaseTarball.php <version> Change-Id: Iac86a255af436d46b7916e9b2b314a52b78e281b --- A make-release/phpunit.xml A make-release/testReleaseTarball.php 2 files changed, 146 insertions(+), 0 deletions(-) Approvals: Hashar: Looks good to me, approved jenkins-bot: Verified diff --git a/make-release/phpunit.xml b/make-release/phpunit.xml new file mode 100644 index 0000000..750c493 --- /dev/null +++ b/make-release/phpunit.xml @@ -0,0 +1,17 @@ +<phpunit + colors="true" + + strict="true" + verbose="true" + + stopOnError="true" + stopOnFailure="true" + stopOnIncomplete="true" + stopOnSkipped="true" + > + <testsuites> + <testsuite name="tarball"> + <file>testReleaseTarball.php</file> + </testsuite> + </testsuites> +</phpunit> diff --git a/make-release/testReleaseTarball.php b/make-release/testReleaseTarball.php new file mode 100644 index 0000000..cde2538 --- /dev/null +++ b/make-release/testReleaseTarball.php @@ -0,0 +1,129 @@ +<?php +/** + * MediaWiki tarball tester. + * + * Based on the PHPUnit Framework. + * + * Usage: + * phpunit [switches] testReleaseTarball.php <version> + * + * Example: + * phpunit --log-junit results.xml testReleaseTarball.php 1.21.2 + * + * @author Markus Glaser + * @file + */ + +/** + * PHPUnit based tests. + */ +class ReleaseTarballTestCase extends PHPUnit_Framework_TestCase { + + /** Version we will test out */ + protected static $version; + + /** Filename of the tarball for the version */ + protected static $tarball; + + /** Path where the tarball got extracted to */ + protected static $basePath; + + /** + * Helper to easily set the target version AND the tarball name + */ + protected static function setTargetVersion( $version ) { + self::$version = $version; + self::$tarball = "build/mediawiki-{$version}.tar.gz"; + self::$basePath = "mediawiki-{$version}"; + } + + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + //version tag is the last argument + self::setTargetVersion( array_pop( $_SERVER['argv'] ) ); + } + + public static function tearDownAfterClass() { + # remove install dir + if ( file_exists( self::$basePath ) && is_dir( self::$basePath ) ) { + # There seems to be a handle on the language files immediately after + # install, so let's wait a bit + sleep(1); + + $cmd = 'rm -r ' . escapeshellarg( self::$basePath ); + exec( $cmd ); + } + + parent::tearDownAfterClass(); + } + + /** + * Make sure the version passed to us is valid + */ + public function testTargetVersionIsValid() { + $this->assertRegExp( '/\d\.\d+\.\d+.*/', + self::$version, + "Must be passed a valid MediaWiki version" + ); + } + + public function testHaveATarballForTargetVersion() { + $this->assertFileExists( self::$tarball, + self::$tarball . " could not be find. Please run: make-release.py " . self::$version + ); + } + + public function testExtractTarball() { + // extract tarball as described in http://www.mediawiki.org/wiki/Manual:Installing_MediaWiki + $cmd = 'tar xzf ' . escapeshellarg( self::$tarball ); + + exec( $cmd, $output, $exitCode ); + $this->assertEquals( 0, $exitCode, + "Shell command $cmd failed with exit code $exitCode" + ); + + # TODO: this assertion is not enough + $this->assertFileExists( self::$basePath, + "Tarball " . self::$tarball . "should have been extracted to " + . self::$basePath + ); + + $this->assertFileExists( self::$basePath . '/includes/DefaultSettings.php', + "DefaultSettings.php could not be found." + ); + } + + public function testWgversionMatchTargetedVersion() { + $file = file_get_contents( self::$basePath . '/includes/DefaultSettings.php' ); + preg_match( '/\$wgVersion\s+=\s+\'(.*)\';/', + $file, $matches + ); + $this->assertEquals( self::$version, + $matches[1], + "\$wgVersion is not set correctly." + ); + } + + public function testCliInstaller() { + $cmd = 'php ' . escapeshellarg( self::$basePath ) . '/maintenance/install.php' + //SQLite for installation + .' --dbtype=sqlite' + //Put SQLite file in MW install path + .' --dbpath=' . escapeshellarg( self::$basePath ) + //admin pass + .' --pass=releaseTest' + //name + .' TarballTestInstallation' + //admin + .' WikiSysop'; + + exec( $cmd, $output, $exitCode ); + $this->assertEquals( 0, $exitCode, + "Shell command $cmd failed with exit code $exitCode" + ); + $this->assertFileExists( self::$basePath . '/LocalSettings.php', + "Installation failed: LocalSettings.php could not be found." + ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/89158 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iac86a255af436d46b7916e9b2b314a52b78e281b Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/tools/release Gerrit-Branch: master Gerrit-Owner: Hashar <has...@free.fr> Gerrit-Reviewer: CSteipp <cste...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: MarkAHershberger <mhershber...@wikimedia.org> Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits