Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug 5587: Give unit test name by __LINE__. #264

Merged
merged 2 commits into from

4 participants

kennytm Alex Rønne Petersen Damian Ziemba Walter Bright
kennytm

http://d.puremagic.com/issues/show_bug.cgi?id=5587

This commit appends 'Lxx' to the unittest's mangled name. The user can get the line number from the traceback:

5   x       0x000091c5 onAssertErrorMsg + 73
6   x       0x00009206 onUnittestErrorMsg + 26
7   x       0x00013199 _d_unittestm + 45
8   x       0x000019d7 void x.__unittest_fail(int) + 27
9   x       0x00001a0a void x.__unittestL13_1() + 46
                                        ^^^ line 13
kennytm added some commits
kennytm kennytm Bug 5587: Give unit test name by __LINE__.
This commit appends 'Lxx' to the unittest's mangled name. The user can get the line number from the traceback:

5   x       0x000091c5 onAssertErrorMsg + 73
6   x       0x00009206 onUnittestErrorMsg + 26
7   x       0x00013199 _d_unittestm + 45
8   x       0x000019d7 void x.__unittest_fail(int) + 27
9   x       0x00001a0a void x.__unittestL13_1() + 46
                                        ^^^ line 13
8f478ac
kennytm kennytm Fix build failure: snprintf doesn't exist on Windows. af9cd30
Alex Rønne Petersen

This really needs to be merged. It would make debugging so much easier.

Damian Ziemba

Ping on this.

Walter Bright WalterBright merged commit d3669f7 into from
Walter Bright WalterBright referenced this pull request from a commit
Walter Bright WalterBright merge D2 pull #264 9850e67
Brad Roberts braddr referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 3, 2012
  1. kennytm

    Bug 5587: Give unit test name by __LINE__.

    kennytm authored
    This commit appends 'Lxx' to the unittest's mangled name. The user can get the line number from the traceback:
    
    5   x       0x000091c5 onAssertErrorMsg + 73
    6   x       0x00009206 onUnittestErrorMsg + 26
    7   x       0x00013199 _d_unittestm + 45
    8   x       0x000019d7 void x.__unittest_fail(int) + 27
    9   x       0x00001a0a void x.__unittestL13_1() + 46
                                            ^^^ line 13
  2. kennytm
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/func.c
14 src/func.c
View
@@ -3812,13 +3812,21 @@ void InvariantDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
* instances per module.
*/
-static Identifier *unitTestId()
+#if __DMC__ || _MSC_VER
+#define snprintf _snprintf
+#endif
+static Identifier *unitTestId(Loc loc)
{
- return Lexer::uniqueId("__unittest");
+ char name[24];
+ snprintf(name, 24, "__unittestL%u_", loc.linnum);
+ return Lexer::uniqueId(name);
}
+#if __DMC__ || _MSC_VER
+#undef snprintf
+#endif
UnitTestDeclaration::UnitTestDeclaration(Loc loc, Loc endloc)
- : FuncDeclaration(loc, endloc, unitTestId(), STCundefined, NULL)
+ : FuncDeclaration(loc, endloc, unitTestId(loc), STCundefined, NULL)
{
}
Something went wrong with that request. Please try again.