On Thu, Nov 3, 2011 at 1:41 PM, Gregory Szorc <
g...@mozilla.com> wrote:
> Following a conversation in #developers, there seems to be a general
> consensus that naming files (especially test files) of the form "bugXXXXXX"
> is silly and should stop. Therefore, I'm proposing that reviewers enforce a
> convention of no *new* files having this naming schema.
>
> Instead, filenames should better reflect what they are actually doing or
> involved with. For tests, create filenames that name the entity being
> tested. For example, instead of "bug_123456.js," use
> "tabbrowser_tab_loading_basic.js."
>
I think your statement is too broad and is incorrect. Naming tests as
bugXXXXXX is not always silly. It totally depends on what the test is
really testing. For example, if I have a test which is supposed to test
the interaction of keyboard event handlings in general, the test can be
named test_keyboard_event_handling or something like that. But if the test
is testing something very specific, such as to make sure that we don't
crash when we flush layout in the middle of an editor update in a document
which has its editable mode switched, naming the test as test_bug123456 is
really the best way I think we can name it, and naming it
test_flush_layout_in_editor_update_if_document_editable_mode_is_switched
would be silly.
I think you can't really generalize a single one-size-fits-all naming
scheme here.
> When adding tests for bugs, add the test case to an existing file which
> holds all the tests for that entity. The test case name should describe
> what is being tested and the code and commit history can be annotated with
> a bug number. e.g.
>
> # Bug 123456 Ensure widget operates as expected
> add_test_case(function test_proper_widget_operation() {
> ...
> });
>
I object to this very strongly. In general, I think we should prefer
smaller, more self-contained tests. Larger tests are harder to understand,
harder to check for correctness, and more likely to suffer from
interdependency issues.
Merging tests just to get the bug numbers out of file names seems like a
very bad idea to me.
> In the end, test cases for related entities are all logically grouped by
> filename, not bug sequence. This is much easier for us mere humans.
>
It actually makes things a lot harder to understand. Try reading this test
for example. ;-) <
http://mxr.mozilla.org/mozilla-central/source/editor/libeditor/html/tests/test_htmleditor_keyevent_handling.html?force=1
>
> For reference, I consider the test suite in services/sync/tests/unit [1]
> to be of mostly valid form.
>
> There was some talk of establishing a repository hook to enforce this
> convention. Personally, I favor social enforcement via code reviews and
> auditing to catch accidental offenders. Bug 698906 [2] has been filed to
> track whatever we decide is best.
>
> Shall we adopt this proposal?
>
No. And until you can make the case why doing this is a net win, we
definitely don't want to ask reviewers to enforce this, or even worse,
enforce it using a repository hook.
Cheers,
--
Ehsan
<
http://ehsanakhgari.org/>