From e69647e23e0eb95f62afa2c09459c77d98c2853b Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Mon, 21 Nov 2016 15:14:34 +0100 Subject: Correct errors in documentation and add more info OTP-14044 --- lib/common_test/doc/src/write_test_chapter.xml | 44 +++++++++++++++++--------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/lib/common_test/doc/src/write_test_chapter.xml b/lib/common_test/doc/src/write_test_chapter.xml index 1d3fbb6f76..f70bdb16c5 100644 --- a/lib/common_test/doc/src/write_test_chapter.xml +++ b/lib/common_test/doc/src/write_test_chapter.xml @@ -986,15 +986,17 @@ io:put_chars/1, and so on.

Importance is compared to a verbosity level set by the - verbosity start flag/option. The verbosity level can be set per - category or generally, or both. The default verbosity level, - ?STD_VERBOSITY, is 50, that is, all standard I/O gets printed. - If a lower verbosity level is set, standard I/O printouts are ignored. - Common Test performs the following test:

+ verbosity start flag/option. The level can be set per + category or generally, or both. If verbosity is not set by the user, + a level of 100 (?MAX_VERBOSITY = all printouts visible) is used as + default value. Common Test performs the following test:

- Importance >= (100-VerbosityLevel)
-

This also means that verbosity level 0 effectively turns all logging off - (except from printouts made by Common Test itself).

+Importance >= (100-VerbosityLevel) +

The constant ?STD_VERBOSITY has value 50 (see ct.hrl). + At this level, all standard I/O gets printed. If a lower verbosity level + is set, standard I/O printouts are ignored. Verbosity level 0 effectively + turns all logging off (except from printouts made by Common Test + itself).

The general verbosity level is not associated with any particular category. This level sets the threshold for the standard I/O printouts, @@ -1003,17 +1005,17 @@

Examples:

Some printouts during test case execution:

-
  
+    
  io:format("1. Standard IO, importance = ~w~n", [?STD_IMPORTANCE]),
  ct:log("2. Uncategorized, importance = ~w", [?STD_IMPORTANCE]),
- ct:log(info, "3. Categorized info, importance = ~w", [?STD_IMPORTANCE]]),
+ ct:log(info, "3. Categorized info, importance = ~w", [?STD_IMPORTANCE]),
  ct:log(info, ?LOW_IMPORTANCE, "4. Categorized info, importance = ~w", [?LOW_IMPORTANCE]),
- ct:log(error, "5. Categorized error, importance = ~w", [?HI_IMPORTANCE]),
- ct:log(error, ?HI_IMPORTANCE, "6. Categorized error, importance = ~w", [?MAX_IMPORTANCE]),
+ ct:log(error, ?HI_IMPORTANCE, "5. Categorized error, importance = ~w", [?HI_IMPORTANCE]), + ct:log(error, ?MAX_IMPORTANCE, "6. Categorized error, importance = ~w", [?MAX_IMPORTANCE]),
-

If starting the test without specifying any verbosity levels as follows:

+

If starting the test with a general verbosity level of 50 (?STD_VERBOSITY):

- $ ct_run ...
+ $ ct_run -verbosity 50

the following is printed:

  1. Standard IO, importance = 50
@@ -1031,10 +1033,22 @@
  4. Categorized info, importance = 25
  6. Categorized error, importance = 99
+

Note that the category argument is not required in order to only specify the + importance of a printout. Example:

+
+ct:pal(?LOW_IMPORTANCE, "Info report: ~p", [Info])
+

Or perhaps in combination with constants:

+
+-define(INFO, ?LOW_IMPORTANCE).
+-define(ERROR, ?HI_IMPORTANCE).
+
+ct:log(?INFO, "Info report: ~p", [Info])
+ct:pal(?ERROR, "Error report: ~p", [Error])
+

The functions ct:set_verbosity/2 and ct:get_verbosity/1 may be used to modify and read verbosity levels during test execution.

- +

The arguments Format and FormatArgs in ct:log/print/pal are always passed on to the STDLIB function io:format/3 (For details, see the io manual page).

-- cgit v1.2.1