[MediaWiki-l] Unit testing your patch before submitting to gerrit

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[MediaWiki-l] Unit testing your patch before submitting to gerrit

Huji Lee
After having worked with gerrit for years, I have finally decided to be a
good citizen and instead of submitting a patch, finding out that Gerritbot
has found issues with it, and re-submitting the patch (and thereby,
generating very long chains of patch sets), I should test my code using
phpcs and phpunit before submitting it :)

The problem is phpunit gives me a lot of errors all the time (see
https://phabricator.wikimedia.org/T175397 ). So I thought I should ask more
experienced developers: how do you test your code before submitting the
patch?

Thanks,

Huji
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing your patch before submitting to gerrit

Bartosz Dziewoński
If unit tests fail for you, that is usually a bug in unit tests. Jenkins
runs them on a clean new MediaWiki installation with all default
settings every time, so there could be issues where the tests depend on
e.g. the wiki content language being English, timezone being UTC, or
some specific page title not existing. If you run into something like
this, please file a task about it.

--
Bartosz Dziewoński

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing your patch before submitting to gerrit

Chad
In reply to this post by Huji Lee
On Mon, Sep 11, 2017 at 4:09 PM Huji Lee <[hidden email]> wrote:

> So I thought I should ask more
> experienced developers: how do you test your code before submitting the
> patch?
>
>
I don't. I live life on the wild side and test in production ;-)

-Chad
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing your patch before submitting to gerrit

Huji Lee
You made me chuckle Chad! Sadly (or gladly), peasants like me cannot test
in production ;)

Bartosz, I will investigate the issues I have found so far and try to file
tasks for each of them. On a relatively clean installation, I got those 7
fatals that I posted T175397 for. In my "actual" test wiki I get more than
120 fatal errors!

Do you guys set up a brand new MedaWiki installation every time? (I am
addressing those who are neither lazy like old me nor dare devils like Chad)

On Mon, Sep 11, 2017 at 7:32 PM, Chad <[hidden email]> wrote:

> On Mon, Sep 11, 2017 at 4:09 PM Huji Lee <[hidden email]> wrote:
>
> > So I thought I should ask more
> > experienced developers: how do you test your code before submitting the
> > patch?
> >
> >
> I don't. I live life on the wild side and test in production ;-)
>
> -Chad
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing your patch before submitting to gerrit

Bartosz Dziewoński
To be honest, I also usually just hope I get it right the first time and
Jenkins doesn't embarrass me... ;) (hey, it's a great time saver when it
works).

When I do need to test locally, it's very helpful to run individual test
cases instead of the whole suite and just pretend the other failures
don't exist:

https://www.mediawiki.org/wiki/Manual:PHP_unit_testing/Running_the_unit_tests#Running_other_sets_of_tests

--
Bartosz Dziewoński

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing your patch before submitting to gerrit

Brian Wolff
In reply to this post by Huji Lee
On Monday, September 11, 2017, Huji Lee <[hidden email]> wrote:
> After having worked with gerrit for years, I have finally decided to be a
> good citizen and instead of submitting a patch, finding out that Gerritbot
> has found issues with it, and re-submitting the patch (and thereby,
> generating very long chains of patch sets), I should test my code using
> phpcs and phpunit before submitting it :)
>
> The problem is phpunit gives me a lot of errors all the time (see
> https://phabricator.wikimedia.org/T175397 ). So I thought I should ask
more
> experienced developers: how do you test your code before submitting the
> patch?
>
> Thanks,
>
> Huji
>

I find phpunit painful to run locally the full thing. There seems to be
plenty false positives (presumably due to my custom LocalSettings.php) and
it takes forever.

Usually what ill do is run a specific test file if im editing stuff around
that area. This doesnt work forall unit tests but is mostly good enough.
E.g.

cd tests/phpunit
php phpunit.php includes/foo/SomethingTest.php

If im editing the parser i usually use the old parser test harness to run
the tests.

And honestly i usually only do that if im doing something riskly. Mostly i
rely on jenkins.

--
brian
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing your patch before submitting to gerrit

addshorewiki
So, one of my 'dreams' here is that once we finish containerizing CI there
will be a set of containers that you can pull and that will run tests
exactly as in CI.

Watch this space...

On Tue, 12 Sep 2017 at 02:22 Brian Wolff <[hidden email]> wrote:

> On Monday, September 11, 2017, Huji Lee <[hidden email]> wrote:
> > After having worked with gerrit for years, I have finally decided to be a
> > good citizen and instead of submitting a patch, finding out that
> Gerritbot
> > has found issues with it, and re-submitting the patch (and thereby,
> > generating very long chains of patch sets), I should test my code using
> > phpcs and phpunit before submitting it :)
> >
> > The problem is phpunit gives me a lot of errors all the time (see
> > https://phabricator.wikimedia.org/T175397 ). So I thought I should ask
> more
> > experienced developers: how do you test your code before submitting the
> > patch?
> >
> > Thanks,
> >
> > Huji
> >
>
> I find phpunit painful to run locally the full thing. There seems to be
> plenty false positives (presumably due to my custom LocalSettings.php) and
> it takes forever.
>
> Usually what ill do is run a specific test file if im editing stuff around
> that area. This doesnt work forall unit tests but is mostly good enough.
> E.g.
>
> cd tests/phpunit
> php phpunit.php includes/foo/SomethingTest.php
>
> If im editing the parser i usually use the old parser test harness to run
> the tests.
>
> And honestly i usually only do that if im doing something riskly. Mostly i
> rely on jenkins.
>
> --
> brian
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l