Heh, how many newlines is enough? Please get rid of these two.
> Tests
> -----
>
> @@ -82,3 +84,20 @@
>
> $ testr init
> $ testr run
> +
> +
> +Tests for PHP license-matching logic
> +....................................
> +
> +There's currently only one unit test file, LicenseHelperTest.php under testing directory. You first need to install the phpunit package from ubuntu repos:
> + $ sudo apt-get install php-unit
> +
> +
> +Recent (as of 2012-05-08) Ubuntu/Debian releases have a broken phpunit package and thus require installation in a different manner:
> + $ sudo apt-get install php-pear
> + $ sudo pear config-set auto_discover 1
> + $ sudo pear install pear.phpunit.de/PHPUnit
> +
> +Then to run the test from the 'testing' directory:
> +$ cd testing/
> +$ phpunit LicenseHelperTest
We've discussed this on IRC: the test is not stable, since
temp_file_name_1 and temp_file_name_2 can end up being named
differently, and file_list can return them in any order.
Best solution for this is to use static names for them (you are already
creating a temp directory to put them in), when you know what ordering
to expect the files in.
As we agreed, if the tempdir is in a system temp dir, we can also get
rid of the finally hack and let stuff stay there when a test fails.
> +
> + /**
> + * getTheme returns a generic Linaro-branded template when
> + * no EULA is present (indicated by eula filename being named
> + * EULA.txt or not).
How's "ste" representing a "generic" Linaro-branded template? This is
for files containing "snowball" in a name, where we return
"ste" (ST-Ericsson).
> + */
> + public function test_getTheme_noEula_snowball()
> + {
> + $eula = "EULA.txt";
> + $filename = "snowball.build.tar.bz2";
> + $this->assertEquals("ste", LicenseHelper::getTheme($eula, $filename));
> + }
> +
> + /**
> + * getTheme returns a generic Linaro-branded template when
> + * no EULA is present (indicated by eula filename being named
> + * EULA.txt or not).
> + */
More copy-paste :)
> + public function test_getTheme_noEula_origen()
> + {
> + $eula = "EULA.txt";
> + $filename = "origen.build.tar.bz2";
> + $this->assertEquals("samsung",
> + LicenseHelper::getTheme($eula, $filename));
> + }
> +
> + /**
> + * getTheme returns a generic Linaro-branded template when
> + * no EULA is present (indicated by eula filename being named
> + * EULA.txt or not).
> + */
Hi Stevan,
Thanks for working on this. We are so close to getting this landed now.
Just a few more comments.
У уто, 08. 05 2012. у 16:11 +0000, Stevan Radaković пише:
> разлике међу датотекама прилог (review-diff.txt)
> === modified file 'README'
> --- README 2012-05-04 17:44:47 +0000
> +++ README 2012-05-08 14:30:26 +0000
> @@ -74,6 +74,8 @@
> build steps, and not as publishing steps.
>
>
> +
> +
Heh, how many newlines is enough? Please get rid of these two.
> Tests ....... ....... ....... ....... .. st.php under testing directory. You first need to install the phpunit package from ubuntu repos: de/PHPUnit
> -----
>
> @@ -82,3 +84,20 @@
>
> $ testr init
> $ testr run
> +
> +
> +Tests for PHP license-matching logic
> +......
> +
> +There's currently only one unit test file, LicenseHelperTe
> + $ sudo apt-get install php-unit
> +
> +
> +Recent (as of 2012-05-08) Ubuntu/Debian releases have a broken phpunit package and thus require installation in a different manner:
> + $ sudo apt-get install php-pear
> + $ sudo pear config-set auto_discover 1
> + $ sudo pear install pear.phpunit.
> +
> +Then to run the test from the 'testing' directory:
> +$ cd testing/
> +$ phpunit LicenseHelperTest
Indent these as well, please :)
> === added file 'licenses/ LicenseHelper. php'
Looks so much better, thanks..
> === added file 'testing/ LicenseHelperTe st.php' LicenseHelperTe st.php 1970-01-01 00:00:00 +0000 LicenseHelperTe st.php 2012-05-08 14:30:26 +0000 Framework_ TestCase once(". ./licenses/ LicenseHelper. php"); temp_filename = tempnam( dirname( __FILE_ _), "unittest");
> --- testing/
> +++ testing/
> @@ -0,0 +1,175 @@
> +<?php
> +
> +class LicenseHelperTest extends PHPUnit_
> +{
> +
> + private $temp_filename;
> +
> + /**
> + * Include test class, create some help files for testing.
> + */
> + protected function setUp()
> + {
> + require_
> + $this->
> + }
Why don't we get rid of the setUp function and move the require_once to
the top of the file, and temp_filename to the single test that requires
it?
> + $this-> temp_filename) ;
> + /**
> + * Remove helper files used in testing.
> + */
> + protected function tearDown()
> + {
> + unlink(
> + }
This will now try to unlink temp_filename even if it's only created in a
single test. Move this to that test, and get rid of th tearDown()
function.
> + /** link() $this-> temp_filename, "test_link"); assertTrue( LicenseHelper: :checkFile( "test_link" )); "test_link" ); "test_link" );
> + * Running checkFile on a symbolic link to an existing file returns true.
> + */
> + public function test_checkFile_
> + {
> + try {
> + symlink(
> + $this->
> + unlink(
> + // PHP doesn't support finally block, ergo using this hack.
> + } catch (Exception $e) {
> + unlink(
> + throw $e;
> + }
> + }
Where's that test for the checkFile on a link to a non-existent file?
Perhaps PHP symlink(tempnam(), "test_link") doesn't work?
> + /** st_dir( ) dirname( __FILE_ _), "unittest"); $temp_dir_ name)) { $temp_dir_ name); temp_dir_ name); $temp_dir_ name, "unittest"); $temp_dir_ name, "unittest"); :getFilesList( $temp_dir_ name); assertCount( 2, $file_list); assertEquals( basename( $temp_file_ name_1) , $file_list[0]); assertEquals( basename( $temp_file_ name_2) , $file_list[1]); $temp_file_ name_1) ; $temp_file_ name_2) ; temp_dir_ name); $temp_file_ name_1) ; $temp_file_ name_2) ; temp_dir_ name);
> + * getFileList returns a list of filenames in that directory.
> + */
> + public function test_getFilesLi
> + {
> + $temp_dir_name = tempnam(
> + if (file_exists(
> + unlink(
> + }
> + mkdir($
> +
> + $temp_file_name_1 = tempnam(
> + $temp_file_name_2 = tempnam(
> +
> + try {
> + $file_list = LicenseHelper:
> + $this->
> +
> + $this->
> + $this->
> +
> + unlink(
> + unlink(
> + rmdir($
> + // PHP doesn't support finally block, ergo using this hack.
> + } catch (Exception $e) {
> + unlink(
> + unlink(
> + rmdir($
> + throw $e;
> + }
> + }
We've discussed this on IRC: the test is not stable, since
temp_file_name_1 and temp_file_name_2 can end up being named
differently, and file_list can return them in any order.
Best solution for this is to use static names for them (you are already
creating a temp directory to put them in), when you know what ordering
to expect the files in.
As we agreed, if the tempdir is in a system temp dir, we can also get
rid of the finally hack and let stuff stay there when a test fails.
> +
> + /**
> + * getTheme returns a generic Linaro-branded template when
> + * no EULA is present (indicated by eula filename being named
> + * EULA.txt or not).
How's "ste" representing a "generic" Linaro-branded template? This is
for files containing "snowball" in a name, where we return
"ste" (ST-Ericsson).
> + */ noEula_ snowball( ) build.tar. bz2"; assertEquals( "ste", LicenseHelper: :getTheme( $eula, $filename));
> + public function test_getTheme_
> + {
> + $eula = "EULA.txt";
> + $filename = "snowball.
> + $this->
> + }
> +
> + /**
> + * getTheme returns a generic Linaro-branded template when
> + * no EULA is present (indicated by eula filename being named
> + * EULA.txt or not).
> + */
More copy-paste :)
> + public function test_getTheme_ noEula_ origen( ) build.tar. bz2"; assertEquals( "samsung" , :getTheme( $eula, $filename));
> + {
> + $eula = "EULA.txt";
> + $filename = "origen.
> + $this->
> + LicenseHelper:
> + }
> +
> + /**
> + * getTheme returns a generic Linaro-branded template when
> + * no EULA is present (indicated by eula filename being named
> + * EULA.txt or not).
> + */
There we go, this one is fine :)
> + public function test_getTheme_ noEula_ generic( ) assertEquals( "linaro" , :getTheme( $eula, $filename));
> + {
> + $eula = "EULA.txt";
> + $filename = "build.tar.bz2";
> + $this->
> + LicenseHelper:
> + }
> +
> + /**
> + * Running geTheme with eula file present (indicated by eula filename
Typo: getTheme.
> + * being named EULA.txt or not) returns extension of eula file. eula() assertEquals( "test", LicenseHelper: :getTheme( $eula, ""));
> + */
> + public function test_getTheme_
> + {
> + $eula = "EULA.txt.test";
> + $this->
> + }
> +
> +}
> +
> +?>
Cheers,
Danilo