Discussion:
[gem5-dev] Unit test naming convention
(too old to reply)
Gabe Black
2018-11-29 00:54:21 UTC
Permalink
Hi folks. We have a few unit tests now, and they are mostly consistently
named by adding test to the file name. For instance the tests for foo.cc
would be in footest.cc.

There are two minor downsides to that. First, that's a bit ugly to read,
and it may look weird if files, for instance, use _ to separate words
instead of squishing everything together, ie foo_bar.cc -> foo_bartest.cc.
Second, if there already is a footest.cc which is not for unit tests (not
super likely, but definitely possible), then the naming gets a little
ambiguous.

Would it make sense to mark tests with .test, so foo.cc -> foo.test.cc?
That's clear to read, more universally consistent, easily grepped for, and
will probably not be ambiguous.

Gabe
Jason Lowe-Power
2018-11-29 01:01:31 UTC
Permalink
That's fine with me!

+1
Post by Gabe Black
Hi folks. We have a few unit tests now, and they are mostly consistently
named by adding test to the file name. For instance the tests for foo.cc
would be in footest.cc.
There are two minor downsides to that. First, that's a bit ugly to read,
and it may look weird if files, for instance, use _ to separate words
instead of squishing everything together, ie foo_bar.cc -> foo_bartest.cc.
Second, if there already is a footest.cc which is not for unit tests (not
super likely, but definitely possible), then the naming gets a little
ambiguous.
Would it make sense to mark tests with .test, so foo.cc -> foo.test.cc?
That's clear to read, more universally consistent, easily grepped for, and
will probably not be ambiguous.
Gabe
_______________________________________________
gem5-dev mailing list
http://m5sim.org/mailman/listinfo/gem5-dev
Ciro Santilli
2018-11-29 11:40:23 UTC
Permalink
I would recommend using _test.cc, and then just prevent any other class from being named as _test.cc.

This is also the recommendation of the Google C++ style guide: https://google.github.io/styleguide/cppguide.html#File_Names

Conceptually, it feels nice as we don't change the simple .cc style we have right now of [a-z_]*.cc for all files, although I can't see any major breakages besides linters complaining.

________________________________
From: gem5-dev <gem5-dev-***@gem5.org> on behalf of Gabe Black <***@google.com>
Sent: Thursday, November 29, 2018 12:54:21 AM
To: gem5 Developer List
Subject: [gem5-dev] Unit test naming convention

Hi folks. We have a few unit tests now, and they are mostly consistently
named by adding test to the file name. For instance the tests for foo.cc
would be in footest.cc.

There are two minor downsides to that. First, that's a bit ugly to read,
and it may look weird if files, for instance, use _ to separate words
instead of squishing everything together, ie foo_bar.cc -> foo_bartest.cc.
Second, if there already is a footest.cc which is not for unit tests (not
super likely, but definitely possible), then the naming gets a little
ambiguous.

Would it make sense to mark tests with .test, so foo.cc -> foo.test.cc?
That's clear to read, more universally consistent, easily grepped for, and
will probably not be ambiguous.

Gabe
_______________________________________________
gem5-dev mailing list
gem5-***@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev
Gabe Black
2018-11-29 23:50:35 UTC
Permalink
Sorry I missed this before I checked in the changes I had. That might make
sense if files consistently used _ in their names, but unfortunately they
don't. I also think it's a little cleaner to have a separate namespace
entirely for things rather than avoiding conflicts by being careful,
although practically sometimes that's easier said than done or makes things
overly cumbersome.

Gabe
Post by Ciro Santilli
I would recommend using _test.cc, and then just prevent any other class
from being named as _test.cc.
https://google.github.io/styleguide/cppguide.html#File_Names
Conceptually, it feels nice as we don't change the simple .cc style we
have right now of [a-z_]*.cc for all files, although I can't see any major
breakages besides linters complaining.
________________________________
Sent: Thursday, November 29, 2018 12:54:21 AM
To: gem5 Developer List
Subject: [gem5-dev] Unit test naming convention
Hi folks. We have a few unit tests now, and they are mostly consistently
named by adding test to the file name. For instance the tests for foo.cc
would be in footest.cc.
There are two minor downsides to that. First, that's a bit ugly to read,
and it may look weird if files, for instance, use _ to separate words
instead of squishing everything together, ie foo_bar.cc -> foo_bartest.cc.
Second, if there already is a footest.cc which is not for unit tests (not
super likely, but definitely possible), then the naming gets a little
ambiguous.
Would it make sense to mark tests with .test, so foo.cc -> foo.test.cc?
That's clear to read, more universally consistent, easily grepped for, and
will probably not be ambiguous.
Gabe
_______________________________________________
gem5-dev mailing list
http://m5sim.org/mailman/listinfo/gem5-dev
_______________________________________________
gem5-dev mailing list
http://m5sim.org/mailman/listinfo/gem5-dev
Loading...