Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing PhpUnit support for windows #8694

Merged
merged 15 commits into from Sep 8, 2015
Merged

Fixing PhpUnit support for windows #8694

merged 15 commits into from Sep 8, 2015

Conversation

ThaDafinser
Copy link
Contributor

Allow running tests on windows
http://forum.piwik.org/read.php?15,126943

Started around with this php console tests:run unit

Did you know? You can run tests faster by disabling xdebug (if you need xdebug, speed up tests by setting xdebug.coverage_enable=0)
Executing command: cd C:\Data\wap\htdocs\GitHub\piwik/tests/PHPUnit && C:\Data\wap\htdocs\GitHub\piwik/vendor/bin/phpunit   --testsuite UnitTests
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.

Runtime:    PHP 5.6.7 with Xdebug 2.3.2
Configuration:  C:\Data\wap\htdocs\GitHub\piwik\tests\PHPUnit\phpunit.xml.dist

..FF.FFFFFFF................................................   60 / 2942 (  2%)
............................................................  120 / 2942 (  4%)
............................................................  180 / 2942 (  6%)
..............................................F..F....F.....  240 / 2942 (  8%)
............................................................  300 / 2942 ( 10%)
............................................................  360 / 2942 ( 12%)
............................................................  420 / 2942 ( 14%)
............................................................  480 / 2942 ( 16%)
......................F.......FF...FFFF.....................  540 / 2942 ( 18%)
........FFFFFFFFFFFFFFFFFF..................................  600 / 2942 ( 20%)
............................................................  660 / 2942 ( 22%)
..............FF.....F.FFF.F...FFFF...........SSFFFF.FFFFF.F  720 / 2942 ( 24%)
F...........................................................  780 / 2942 ( 26%)
............................................................  840 / 2942 ( 28%)
............................................................  900 / 2942 ( 30%)
............................................................  960 / 2942 ( 32%)
............................................................ 1020 / 2942 ( 34%)
............................................................ 1080 / 2942 ( 36%)
............................................................ 1140 / 2942 ( 38%)
............................................................ 1200 / 2942 ( 40%)
............................................................ 1260 / 2942 ( 42%)
............................................................ 1320 / 2942 ( 44%)
............................................................ 1380 / 2942 ( 46%)
.F..FF.F.F...FFFFFFFFF.FFF.....F..FFFFFFFFFFFFF............. 1440 / 2942 ( 48%)
..............................................FFFFFFFFFFFFFF 1500 / 2942 ( 50%)
FFFFFF...................................................... 1560 / 2942 ( 53%)
............................................................ 1620 / 2942 ( 55%)
............................................................ 1680 / 2942 ( 57%)
............................................................ 1740 / 2942 ( 59%)
............................................................ 1800 / 2942 ( 61%)
............................................................ 1860 / 2942 ( 63%)
............................................................ 1920 / 2942 ( 65%)
............................................................ 1980 / 2942 ( 67%)
............................................................ 2040 / 2942 ( 69%)
............................................................ 2100 / 2942 ( 71%)
............................................................ 2160 / 2942 ( 73%)
............................................................ 2220 / 2942 ( 75%)
............................................................ 2280 / 2942 ( 77%)
............................................................ 2340 / 2942 ( 79%)
............................................................ 2400 / 2942 ( 81%)
............................................................ 2460 / 2942 ( 83%)
............................................................ 2520 / 2942 ( 85%)
............................................................ 2580 / 2942 ( 87%)
............................................................ 2640 / 2942 ( 89%)
............................................................ 2700 / 2942 ( 91%)
............................................................ 2760 / 2942 ( 93%)
............................................................ 2820 / 2942 ( 95%)
.............E.............................................. 2880 / 2942 ( 97%)
............................................................ 2940 / 2942 ( 99%)

@ThaDafinser ThaDafinser changed the title Feature/windows [WIP] Feature/windows Sep 2, 2015
@ThaDafinser
Copy link
Contributor Author

i executed vendor\bin\php-cs-fixer fix [PATHS...] --fixers=linefeed for the newline problems

folders: core/plugins/tests

@ThaDafinser
Copy link
Contributor Author

Getting closer...

@ThaDafinser
Copy link
Contributor Author

The unit test run now all on windows, expect one...but thats hard to fix since its a file lock with a parallel request!

@tsteur i'm done with it...if you think its good you can merge it.


C:\Data\wap\htdocs\GitHub\piwik>php console tests:run unit
Did you know? You can run tests faster by disabling xdebug (if you need xdebug,
speed up tests by setting xdebug.coverage_enable=0)
Executing command: cd C:\Data\wap\htdocs\GitHub\piwik/tests/PHPUnit && C:\Data\w
ap\htdocs\GitHub\piwik/vendor/bin/phpunit   --testsuite UnitTests
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.

Runtime:        PHP 5.6.7 with Xdebug 2.3.2
Configuration:  C:\Data\wap\htdocs\GitHub\piwik\tests\PHPUnit\phpunit.xml.dist

............................................................   60 / 2942 (  2%)
............................................................  120 / 2942 (  4%)
............................................................  180 / 2942 (  6%)
............................................................  240 / 2942 (  8%)
............................................................  300 / 2942 ( 10%)
............................................................  360 / 2942 ( 12%)
............................................................  420 / 2942 ( 14%)
............................................................  480 / 2942 ( 16%)
............................................................  540 / 2942 ( 18%)
............................................................  600 / 2942 ( 20%)
............................................................  660 / 2942 ( 22%)
..............................................SS.........S..  720 / 2942 ( 24%)
............................................................  780 / 2942 ( 26%)
............................................................  840 / 2942 ( 28%)
............................................................  900 / 2942 ( 30%)
............................................................  960 / 2942 ( 32%)
............................................................ 1020 / 2942 ( 34%)
............................................................ 1080 / 2942 ( 36%)
............................................................ 1140 / 2942 ( 38%)
............................................................ 1200 / 2942 ( 40%)
............................................................ 1260 / 2942 ( 42%)
............................................................ 1320 / 2942 ( 44%)
............................................................ 1380 / 2942 ( 46%)
............................................................ 1440 / 2942 ( 48%)
............................................................ 1500 / 2942 ( 50%)
............................................................ 1560 / 2942 ( 53%)
............................................................ 1620 / 2942 ( 55%)
............................................................ 1680 / 2942 ( 57%)
............................................................ 1740 / 2942 ( 59%)
............................................................ 1800 / 2942 ( 61%)
............................................................ 1860 / 2942 ( 63%)
............................................................ 1920 / 2942 ( 65%)
............................................................ 1980 / 2942 ( 67%)
............................................................ 2040 / 2942 ( 69%)
............................................................ 2100 / 2942 ( 71%)
............................................................ 2160 / 2942 ( 73%)
............................................................ 2220 / 2942 ( 75%)
............................................................ 2280 / 2942 ( 77%)
............................................................ 2340 / 2942 ( 79%)
............................................................ 2400 / 2942 ( 81%)
............................................................ 2460 / 2942 ( 83%)
............................................................ 2520 / 2942 ( 85%)
............................................................ 2580 / 2942 ( 87%)
............................................................ 2640 / 2942 ( 89%)
............................................................ 2700 / 2942 ( 91%)
............................................................ 2760 / 2942 ( 93%)
............................................................ 2820 / 2942 ( 95%)
.............E.............................................. 2880 / 2942 ( 97%)
............................................................ 2940 / 2942 ( 99%)
..

Time: 1.55 minutes, Memory: 49.50Mb

There was 1 error:

1) Piwik\Plugins\UserCountry\tests\Unit\UserCountryTest::testGeoIpUpdaterRedunda
ntChecks
rename(C:\Data\wap\htdocs\GitHub\piwik/tests/lib/geoip-files/GeoIPISP.dat,C:\Dat
a\wap\htdocs\GitHub\piwik/tests/lib/geoip-files/GeoIPISP.dat.broken): Der Prozes
s kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet
 wird. (code: 32)

C:\Data\wap\htdocs\GitHub\piwik\plugins\UserCountry\GeoIPAutoUpdater.php:563
C:\Data\wap\htdocs\GitHub\piwik\plugins\UserCountry\tests\Unit\UserCountryTest.p
hp:181
C:\Data\wap\htdocs\GitHub\piwik\plugins\UserCountry\tests\Unit\UserCountryTest.p
hp:92

--

There were 3 skipped tests:

1) Piwik\Tests\Unit\Metrics\FormatterTest::test_getPrettyTimeFromSeconds_Returns
CorrectResult with data set #6 (31536000, array('365 days 0 hours', '8760:00:00'
))
Will not pass on 32-bit machine.

C:\Data\wap\htdocs\GitHub\piwik\tests\PHPUnit\Unit\Metrics\FormatterTest.php:116


2) Piwik\Tests\Unit\Metrics\FormatterTest::test_getPrettyTimeFromSeconds_Returns
CorrectResult with data set #7 (32421600.0, array('1 years 10 days', '9006:00:00
'))
Will not pass on 32-bit machine.

C:\Data\wap\htdocs\GitHub\piwik\tests\PHPUnit\Unit\Metrics\FormatterTest.php:116


3) Piwik\Tests\Unit\Metrics\FormatterTest::test_getPrettyTimeFromSeconds_Returns
CorrectResult with data set #17 (-31536000, array('-365 days 0 hours', '-8760:00
:00'))
Will not pass on 32-bit machine.

C:\Data\wap\htdocs\GitHub\piwik\tests\PHPUnit\Unit\Metrics\FormatterTest.php:116


FAILURES!
Tests: 2942, Assertions: 5865, Errors: 1, Skipped: 3.


C:\Data\wap\htdocs\GitHub\piwik>

@ThaDafinser ThaDafinser changed the title [WIP] Feature/windows Fixing PhpUnit support for windows Sep 2, 2015
@tsteur
Copy link
Member

tsteur commented Sep 2, 2015

I'm getting the same error under Linux/Ubuntu. Never looked into it.

@ThaDafinser
Copy link
Contributor Author

After this is merged, i will look into #8648 again

setlocale(LC_CTYPE, '');
}

public static function setDefaultLocale()
{
self::setLocale('en_US.UTF-8');
self::setLocale(['en_US.UTF-8', 'en-US']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: we still need to use php 5.3 array notation

did you make this change because you do not have utf8 locales on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattab
Copy link
Member

mattab commented Sep 3, 2015

Left a comment, otherwise looks good to me 👍

@ThaDafinser
Copy link
Contributor Author

@mattab ty for the review. I changed that line

mattab pushed a commit that referenced this pull request Sep 8, 2015
Fixing PhpUnit support for windows
@mattab mattab merged commit 9c2ae2b into matomo-org:master Sep 8, 2015
@mattab
Copy link
Member

mattab commented Sep 8, 2015

Thanks @ThaDafinser - btw are tests passing on your Windows machine now?

@ThaDafinser
Copy link
Contributor Author

@mattab with this PR yes. Expect this error

There was 1 error:

1) Piwik\Plugins\UserCountry\tests\Unit\UserCountryTest::testGeoIpUpdaterRedunda
ntChecks
rename(C:\Data\wap\htdocs\GitHub\piwik/tests/lib/geoip-files/GeoIPISP.dat,C:\Dat
a\wap\htdocs\GitHub\piwik/tests/lib/geoip-files/GeoIPISP.dat.broken): Der Prozes
s kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet
 wird. (code: 32)

C:\Data\wap\htdocs\GitHub\piwik\plugins\UserCountry\GeoIPAutoUpdater.php:563
C:\Data\wap\htdocs\GitHub\piwik\plugins\UserCountry\tests\Unit\UserCountryTest.p
hp:181
C:\Data\wap\htdocs\GitHub\piwik\plugins\UserCountry\tests\Unit\UserCountryTest.p
hp:92

@mattab
Copy link
Member

mattab commented Sep 11, 2015

from @diosmosis

just a note: since the addition of https://github.com/piwik/piwik/blob/master/.gitattributes it is now required to add an entry to the file when adding a new type of binary file to the repo (eg, *.bz2 binary)

tsteur added a commit to matomo-org/developer-documentation that referenced this pull request Sep 11, 2015
I think switching between branches became problematic because of matomo-org/matomo#8694
@tsteur
Copy link
Member

tsteur commented Sep 11, 2015

@ThaDafinser I'm having problems when switching between branches that do not contain this .gitattributes. I often see uncommited changes but cannot do a git checkout etc. git checkout simply does nothing. Then I'm not able to switch to another branch.

Our developer docs generator had similar problems and workaround for now is to stop switching between branches: matomo-org/developer-documentation#102

Do you know what I mean? Have you ever had such problems? Do you maybe know how to fix it?

@ThaDafinser
Copy link
Contributor Author

@tsteur i had that problems some time ago - the changes are just the diff between \n and \r\n

_Solution should be_ https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings

@tsteur
Copy link
Member

tsteur commented Sep 22, 2015

It kinda works but always have to do it when switching to master because of a few files eg (.gz files). Is there a more permanent solution do this? It always takes me a couple of minutes to switch to eg master

@ThaDafinser
Copy link
Contributor Author

@tsteur then we have to add the .gz files too ignore that

from @diosmosis

just a note: since the addition of https://github.com/piwik/piwik/blob/master/.gitattributes it is now required to add an entry to the file when adding a new type of binary file to the repo (eg, *.bz2 binary)

@ThaDafinser
Copy link
Contributor Author

A side note: This addition will ensure in the future, that there are no compability issues between the OS which is used by developers. It's also a part of psr-2 (or 1?) so it will help a lot.

@tsteur
Copy link
Member

tsteur commented Sep 23, 2015

I think .gz is already listed here, I'll have a look next time I face that issue again. Yes I definitely see a value in it just wondering if there's a more efficient way to switch between branches :)

@tsteur
Copy link
Member

tsteur commented Sep 23, 2015

It's actually those files that make me trouble:

    modified:   tests/javascript/frameworks/ext/ext-all-2.3.0.js
    modified:   tests/javascript/frameworks/ext/ext-base-2.3.0.js
    modified:   tests/javascript/frameworks/jquery/jquery-1.0.4.js
    modified:   tests/javascript/frameworks/jquery/jquery-1.3.2.js

@diosmosis
Copy link
Member

@tsteur This happens when switching to a branch older than the .gitattributes file. You can deal w/ this by:

git checkout troublesome_branch
git commit -a -m "Redundant normalization"
git rebase master # rebasing will end up removing the commit above since it is redundant w/ master

After this, you won't see the problem for the branch.

@tsteur
Copy link
Member

tsteur commented Sep 24, 2015

Thx a lot I'll try it next time

@tsteur
Copy link
Member

tsteur commented Sep 24, 2015

I think it worked, thx! Only the rebasing hurt a lot this time hehe (there were many changes in many places :) )

@sgiehl
Copy link
Member

sgiehl commented Sep 25, 2015

Guess that .gitattributes are also causing some test failures for plugins... See https://travis-ci.org/piwik/plugin-TasksTimetable/builds/82189993 or https://travis-ci.org/PiwikPRO/plugin-InterSites/jobs/82195390

@ThaDafinser
Copy link
Contributor Author

Another way would be to define only some filetypes:

*.php eol=lf
*.xml eol=lf

http://permalink.gmane.org/gmane.comp.version-control.git/266905

This will correctly normalize text files in the repo. However, the
second part (LF forcing on checkout) cannot be achieved easily today
because adding eol=lf will unfortunately process binary files too.
The only solution today is to mark certain types for conversion (e.g.,
*.txt eol=lf) or, inversely, mark certain types as binary (e.g.,
*.png binary).

@mattab
Copy link
Member

mattab commented Oct 1, 2015

@sgiehl @ThaDafinser Created issue: #8879 - any idea or even PR welcome

@mattab mattab added c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. labels Oct 13, 2015
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Tests & QA For issues related to automated tests or making it easier to QA & test issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants