Skip to content

Commit d11ba21

Browse files
committed
Add information about ct:comment to documentation
1 parent 2920d74 commit d11ba21

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/common_test/doc/guides/ct_hooks_chapter.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,22 @@ After any post hook has been executed for all installed CTHs,
281281
skipped, respectively. You cannot affect the outcome of the tests any further at
282282
this point.
283283

284+
[](){: #comment }
285+
286+
### Comment in hooks
287+
288+
As mentioned in `ct:comment/1` same limitation regarding calling `ct:comment/1-2`
289+
exists in hook functions. Calling `ct:comment/1-2` should only be done directly from
290+
the process executing hook function, or it's descendant.
291+
292+
Be aware that if you spawn a process in one hook function and keep it alive
293+
while common_test has moved to calling another hook function, and you try to
294+
execute `ct:comment/1-2` from this process the comment may not be printed in
295+
correct place in html logs, or at all.
296+
297+
Calling this function from process that is neither a common_test process, nor it's
298+
descendant is no-op.
299+
284300
[](){: #synchronizing }
285301

286302
## Synchronizing External User Applications with Common Test

lib/common_test/src/ct.erl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,20 @@ suite result page.
10551055

10561056
If called several times, only the last comment is printed. The test case return
10571057
value `{comment,Comment}` overwrites the string set by this function.
1058+
1059+
> #### Warning {: .warning }
1060+
>
1061+
> This function (and `ct:comment/2`) should only be called from the process running
1062+
> the common_test functions, typically the test case process or it's descendant.
1063+
> Be aware that if you spawn a new process in one common_test function (e.g. `init_per_suite`)
1064+
> and then execute `ct:comment/1-2` in that new process while the test execution has moved
1065+
> to another common_test function (e.g. `init_per_testcase` or test case function) the comment
1066+
> might not be printed in the correct place in html logs or at all.
1067+
>
1068+
> Calling this function from process that is neither a common_test process, nor it's
1069+
> descendant is no-op.
1070+
>
1071+
> Similar limitation exists for common_test hooks, see: [Comment in hooks](ct_hooks_chapter.md#comment)
10581072
""".
10591073
-spec comment(Comment) -> ok
10601074
when Comment :: term().

0 commit comments

Comments
 (0)