Skip to content

Commit ae96ba3

Browse files
authored
Merge pull request #4526 from guy-maurel/Debug_Tracking
reform part of test_cli_options.py
2 parents ed1800f + 04bb94b commit ae96ba3

File tree

4 files changed

+92
-13
lines changed

4 files changed

+92
-13
lines changed

src/output.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,34 @@ void output_text(FILE *pfile)
836836
__func__, __LINE__, pc->ElidedText(copy), get_token_name(pc->GetType()), pc->GetOrigLine(), pc->GetColumn(), pc->GetNlCount());
837837
cpd.output_tab_as_space = false;
838838

839+
if ( pc->Is(CT_STRING)
840+
&& tracking_is_on)
841+
{
842+
// prepare the string for the HTML-output
843+
LOG_FMT(LCONTTEXT, "%s(%d): STRING\n",
844+
__func__, __LINE__);
845+
size_t len = pc->Len();
846+
UncText u = pc->Str();
847+
848+
for (size_t idx = 0; idx < len; idx++)
849+
{
850+
int c = u[idx];
851+
852+
if (c == '<')
853+
{
854+
add_text("&lt;"); // 60
855+
}
856+
else if (c == '>')
857+
{
858+
add_text("&gt;"); // 62
859+
}
860+
else
861+
{
862+
add_char(c);
863+
}
864+
}
865+
}
866+
839867
if (pc->Is(CT_NEWLINE))
840868
{
841869
DecodeTrackingData(pc);

tests/cli/input/tracking_space.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#include <header>
2+
#include<header>
3+
14
{
25
a = b + 111-55;
36
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
4+
<title>Uncrustify: where do the Spaces options work</title>
5+
</head>
6+
<body lang="en-US">
7+
<p>
8+
</p>
9+
<pre>
10+
#<a title="IGNORE: 2&#010;pp_space_after: 1"><font color="red">M</font></a>include<a title="ADD from add_space_table @ 181.: 3, 94"><font color="red">M</font></a>&lt;header&gt;<header><a title="REMOVE: 4, 95, 96"><font color="red">M</font></a>
11+
#<a title="IGNORE: 6&#010;pp_space_after: 5"><font color="red">M</font></a>include<a title="ADD from add_space_table @ 181.: 7, 97"><font color="red">M</font></a>&lt;header&gt;<header><a title="REMOVE: 8, 98, 99"><font color="red">M</font></a>
12+
13+
{<a title="REMOVE: 9"><font color="red">M</font></a>
14+
a<a title="sp_assign: 10"><font color="red">M</font></a>=<a title="sp_assign: 11, 100"><font color="red">M</font></a>b<a title="sp_arith: 12, 101, 107"><font color="red">M</font></a>+<a title="sp_arith: 13, 102, 108, 113"><font color="red">M</font></a>111<a title="sp_arith: 14, 103, 109, 114, 118"><font color="red">M</font></a>-<a title="sp_arith: 15, 104, 110, 115, 119, 122"><font color="red">M</font></a>55<a title="sp_before_semi: 16, 105, 111, 116, 120, 123, 125"><font color="red">M</font></a>;<a title="REMOVE: 17, 106, 112, 117, 121, 124, 126, 127"><font color="red">M</font></a>
15+
}<a title="REMOVE: 18"><font color="red">M</font></a>
16+
template<a title="sp_before_angle: 19"><font color="red">M</font></a>&lt;<a title="sp_inside_angle: 20, 128"><font color="red">M</font></a>typename<a title="ADD from add_space_table @ 251.: 21, 129, 137"><font color="red">M</font></a>...<a title="sp_ellipsis_parameter_pack: 22, 130, 138, 145"><font color="red">M</font></a>A<a title="sp_before_comma: 23, 131, 139, 146, 152"><font color="red">M</font></a>,<a title="sp_after_comma: 24, 132, 140, 147, 153, 158"><font color="red">M</font></a>int<a title="sp_type_ellipsis: 25, 133, 141, 148, 154, 159, 163"><font color="red">M</font></a>...<a title="FORCE: 26, 134, 142, 149, 155, 160, 164, 167"><font color="red">M</font></a>B<a title="sp_inside_angle: 27, 135, 143, 150, 156, 161, 165, 168, 170"><font color="red">M</font></a>&gt;<a title="REMOVE: 28, 136, 144, 151, 157, 162, 166, 169, 171, 172"><font color="red">M</font></a>
17+
struct<a title="sp_struct_type: 29"><font color="red">M</font></a>foo1<a title="sp_after_type: 30, 173"><font color="red">M</font></a>:<a title="ADD from add_space_table @ 49.: 31, 174, 191"><font color="red">M</font></a>foo1<a title="sp_before_angle: 32, 175, 192, 208"><font color="red">M</font></a>&lt;<a title="sp_inside_angle: 33, 176, 193, 209, 224"><font color="red">M</font></a>A<a title="sp_parameter_pack_ellipsis: 34, 177, 194, 210, 225, 239"><font color="red">M</font></a>...<a title="sp_before_comma: 35, 178, 195, 211, 226, 240, 253"><font color="red">M</font></a>,<a title="sp_after_comma: 36, 179, 196, 212, 227, 241, 254, 266"><font color="red">M</font></a>(<a title="sp_inside_paren: 37, 180, 197, 213, 228, 242, 255, 267, 278"><font color="red">M</font></a>sizeof<a title="sp_sizeof_ellipsis: 38, 181, 198, 214, 229, 243, 256, 268, 279, 289"><font color="red">M</font></a>...<a title="sp_sizeof_ellipsis_paren: 39, 182, 199, 215, 230, 244, 257, 269, 280, 290, 299"><font color="red">M</font></a>(<a title="sp_inside_paren: 40, 183, 200, 216, 231, 245, 258, 270, 281, 291, 300, 308"><font color="red">M</font></a>A<a title="sp_inside_paren: 41, 184, 201, 217, 232, 246, 259, 271, 282, 292, 301, 309, 316"><font color="red">M</font></a>)<a title="sp_arith: 42, 185, 202, 218, 233, 247, 260, 272, 283, 293, 302, 310, 317, 323"><font color="red">M</font></a>+<a title="sp_arith: 43, 186, 203, 219, 234, 248, 261, 273, 284, 294, 303, 311, 318, 324, 329"><font color="red">M</font></a>B<a title="sp_inside_paren: 44, 187, 204, 220, 235, 249, 262, 274, 285, 295, 304, 312, 319, 325, 330, 334"><font color="red">M</font></a>)<a title="sp_paren_ellipsis: 286, 338, 335, 331, 326, 320, 313, 305, 296, 45, 275, 263, 250, 236, 221, 205, 188"><font color="red">M</font></a>...<a title="sp_inside_angle: 297, 341, 339, 336, 332, 327, 321, 314, 306, 46, 287, 276, 264, 251, 237, 222, 206, 189"><font color="red">M</font></a>&gt;<a title="REMOVE: 298, 343, 342, 340, 337, 333, 328, 322, 315, 307, 47, 288, 277, 265, 252, 238, 223, 207, 190"><font color="red">M</font></a>
18+
{<a title="REMOVE: 48"><font color="red">M</font></a>
19+
foo1<a title="sp_func_class_paren: 49, 72"><font color="red">M</font></a>(<a title="sp_inside_fparens: 50, 73, 344"><font color="red">M</font></a>)<a title="sp_fparen_brace: 51, 74, 345, 347"><font color="red">M</font></a>{<a title="REMOVE: 52, 75, 346, 348, 349"><font color="red">M</font></a>
20+
int<a title="sp_after_type: 53, 76"><font color="red">M</font></a>x<a title="sp_assign: 54, 77, 350"><font color="red">M</font></a>=<a title="sp_assign: 55, 78, 351, 358"><font color="red">M</font></a>sizeof<a title="sp_sizeof_ellipsis: 56, 79, 352, 359, 365"><font color="red">M</font></a>...<a title="sp_sizeof_ellipsis_paren: 57, 80, 353, 360, 366, 371"><font color="red">M</font></a>(<a title="sp_inside_paren: 58, 81, 354, 361, 367, 372, 376"><font color="red">M</font></a>A<a title="sp_inside_paren: 59, 82, 355, 362, 368, 373, 377, 380"><font color="red">M</font></a>)<a title="sp_before_semi: 60, 83, 356, 363, 369, 374, 378, 381, 383"><font color="red">M</font></a>;<a title="REMOVE: 61, 84, 357, 364, 370, 375, 379, 382, 384, 385"><font color="red">M</font></a>
21+
bool<a title="sp_after_type: 62, 85"><font color="red">M</font></a>b<a title="sp_assign: 63, 86, 386"><font color="red">M</font></a>=<a title="sp_assign: 64, 87, 387, 392"><font color="red">M</font></a>x<a title="sp_compare: 65, 88, 388, 393, 397"><font color="red">M</font></a>><a title="sp_compare: 66, 89, 389, 394, 398, 401"><font color="red">M</font></a>1<a title="sp_before_semi: 67, 90, 390, 395, 399, 402, 404"><font color="red">M</font></a>;<a title="REMOVE: 68, 91, 391, 396, 400, 403, 405, 406"><font color="red">M</font></a>
22+
}<a title="REMOVE: 69, 92"><font color="red">M</font></a>
23+
}<a title="sp_before_semi: 70"><font color="red">M</font></a>;<a title="REMOVE: 71, 407"><font color="red">M</font></a>
24+
</pre>
25+
</body>
26+
</html>

tests/cli/test_cli_options.py

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,20 @@ def check_uncrustify_output(
352352
----------------------------------------------------------------------------
353353
True if all specified files match up, False otherwise
354354
"""
355+
# for debugging purpose
356+
print("D: uncr_bin is:", uncr_bin)
357+
print("D: program_args is:", program_args)
358+
print("D: args_arr is:", args_arr)
359+
print("D: out_expected_path is:", out_expected_path)
360+
print("D: out_result_manip is:", out_result_manip)
361+
print("D: out_result_path is:", out_result_path)
362+
print("D: err_expected_path is:", err_expected_path)
363+
print("D: err_result_manip is:", err_result_manip)
364+
print("D: err_result_path is:", err_result_path)
365+
print("D: gen_expected_path is:", gen_expected_path)
366+
print("D: gen_result_manip is:", gen_result_manip)
367+
print("D: gen_result_path is:", gen_result_path)
368+
355369
# check param sanity
356370
if not out_expected_path and not err_expected_path and not gen_expected_path:
357371
eprint("No expected comparison file provided")
@@ -528,6 +542,7 @@ def main(args):
528542
print("Summary:")
529543
print("Python version is: "+sys.version)
530544
print("OS is: %s" % os_name)
545+
print("")
531546

532547
clear_dir(s_path_join(test_dir, 'results'))
533548

@@ -884,29 +899,36 @@ def main(args):
884899
return_flag = False
885900
print("Test p and debug-csv-format option is OK")
886901

902+
#G#config_D_R = parsed_args.config.lower()
903+
#G#print("config is", config_D_R)
887904
if parsed_args.config.lower() == 'debug':
888905
print("Test tracking space:FILE ...")
889-
print(" config is Debug")
890906
#
891907
# Test tracking space:FILE
892908
#
893-
if os_name != 'nt':
894-
# doesn't work under windows
909+
if os_name == 'nt':
910+
print("doesn't work under windows")
911+
else:
895912
temp_result_path = s_path_join(script_dir, 'results/Debug_tracking_space.html')
896-
abc = "space:" + temp_result_path # Issue #4066
897-
if not check_uncrustify_output(
913+
args_arr=['-c', s_path_join(script_dir, 'config/tracking_space.cfg'),
914+
'-f', s_path_join(script_dir, 'input/tracking_space.cpp'),
915+
'--tracking', "space:" + temp_result_path
916+
]
917+
print(args_arr)
918+
return_value = check_uncrustify_output(
898919
uncr_bin,
899920
parsed_args,
900-
args_arr=['-c', s_path_join(script_dir, 'config/tracking_space.cfg'),
901-
'-f', s_path_join(script_dir, 'input/tracking_space.cpp'),
902-
'--tracking',
903-
abc,
904-
],
921+
args_arr,
905922
gen_expected_path=s_path_join(script_dir, 'output/Debug_tracking_space.html'),
906923
gen_result_path=temp_result_path
907-
):
908-
return_flag = False
909-
print("Test tracking space:FILE is OK")
924+
)
925+
if not return_value:
926+
sys_exit(EX_SOFTWARE)
927+
else:
928+
print("nothing to do")
929+
930+
print("Test tracking space:FILE is OK")
931+
910932

911933
print("Test replace ...")
912934
#

0 commit comments

Comments
 (0)