diff --git a/.gitattributes b/.gitattributes index c026f003bf30a1d36477dfefa703f373b57df054..596eee3741acb525c202c409bc26162a57167411 100644 --- a/.gitattributes +++ b/.gitattributes @@ -830,7 +830,6 @@ testfont binary /src/post_modules/Unicode/normalize.h foreign_ident /src/post_modules/Unicode/split.c foreign_ident /src/post_modules/Unicode/split.h foreign_ident -/src/post_modules/Unicode/test.pike foreign_ident /src/post_modules/Unicode/unicode_module.cmod foreign_ident /src/post_modules/_ADT/Makefile.in foreign_ident /src/post_modules/_ADT/adt.cmod foreign_ident @@ -869,7 +868,6 @@ testfont binary /src/svalue.c foreign_ident /src/svalue.h foreign_ident /src/test_co.pike foreign_ident -/src/testsuite.in foreign_ident /src/time_stuff.h foreign_ident /src/tmodule.c foreign_ident /src/treeopt.in foreign_ident diff --git a/src/post_modules/Unicode/test.pike b/src/post_modules/Unicode/test.pike index 29da40e0d1c50775a74038500d048048c6f4dce2..c234345cbb44d9b77deb8076e12dde350fc43305 100644 --- a/src/post_modules/Unicode/test.pike +++ b/src/post_modules/Unicode/test.pike @@ -1,6 +1,6 @@ #! /usr/bin/env pike -// $Id: test.pike,v 1.8 2007/06/17 23:20:41 mast Exp $ +// $Id$ #define c1 c[0] #define c2 c[1] @@ -8,11 +8,27 @@ #define c4 c[3] #define c5 c[4] +constant log_msg = Tools.Testsuite.log_msg; +constant log_status = Tools.Testsuite.log_status; + int tests, fail; -array(string) argv = ({"dummy", combine_path (__FILE__, "..")}); -array(int) a() +void main(int argc, array argv) { + if (getenv()->TEST_VERBOSITY) + // Run from testsuite. + argv = ({"dummy", combine_path (__FILE__, "..")}); + else { + write("Performing Unicode normalization tests\n"); + write("See http://www.unicode.org/Public/3.2-Update/NormalizationTest-3.2.0.txt\n"); + if( argc<2 || has_value( argv, "--help" ) ) + { + write("\nUsage %s <path>\nwhere path is the path to the directory with the NormalizationTest.txt file.\n", + argv[0]); + exit(0); + } + } + int part, opl; foreach( Stdio.File( argv[1]+"/NormalizationTest.txt","r" )->read()/"\n", string l ) @@ -22,10 +38,9 @@ array(int) a() if( l[0] == '@' ) { - if( opl ) write("Done. "+(tests-opl+1)+" tests.\n" ); - write("\n"); + if( opl ) log_status("Done. "+(tests-opl+1)+" tests." ); opl = tests+1; - write( replace( l[1..], " #", ":") +"\n" ); + log_status( replace( l[1..], " #", ":")); part++; continue; } @@ -51,12 +66,11 @@ array(int) a() foreach( t, string tt ) if( Unicode.normalize( tt, method ) != ok ) { - write("\n"); - werror("Test %d/%s failed:\n" - "expected: %s\n" - "got: %s\n" - "input: %s\n",tests/6,method, - hex(ok), hex(Unicode.normalize(tt,method)), hex(tt)); + log_msg("Test %d/%s failed:\n" + "expected: %s\n" + "got: %s\n" + "input: %s\n",tests/6,method, + hex(ok), hex(Unicode.normalize(tt,method)), hex(tt)); fail++; return; } @@ -73,23 +87,8 @@ array(int) a() test( c4, "NFKC", c1, c2, c3, c4, c5 ); test( c5, "NFKD", c1, c2, c3, c4, c5 ); } - write( "Done. "+(tests-opl+1)+" tests.\n" ); - - return ({tests, fail}); -} - -void main(int argc, array argv) -{ - - write("Performing Unicode normalization tests\n"); - write("See http://www.unicode.org/Public/3.2-Update/NormalizationTest-3.2.0.txt\n"); - if( argc<2 || has_value( argv, "--help" ) ) - { - write("\nUsage %s <path>\nwhere path is the path to the directory with the NormalizationTest.txt file.\n", - argv[0]); - exit(0); - } + log_status( "Done. "+(tests-opl+1)+" tests." ); - global::argv = argv; - a(); + Tools.Testsuite.report_result (tests - fail, fail, 0); + return 0; } diff --git a/src/post_modules/Unicode/testsuite.in b/src/post_modules/Unicode/testsuite.in index b45013b04d4bfd89d118da0cbd74882dadbbf21f..b947e353bc81978ecf1b9001588207e8997dce6b 100644 --- a/src/post_modules/Unicode/testsuite.in +++ b/src/post_modules/Unicode/testsuite.in @@ -3,7 +3,9 @@ START_MARKER test_eq(Unicode.normalize ("\u00bd", "NFKD"), "1\u20442") test_equal(Unicode.split_words_and_normalize ("\u00bd"), ({"1", "2"})) -test_tests([[inherit "]]SRCDIR[[/test.pike";]]) +test_tests([[ + array a() {return Tools.Testsuite.run_script ("]]SRCDIR[[/test.pike");} +]]) test_eq( Unicode.is_wordchar(0), 0 ) test_eq( Unicode.is_wordchar(65), 1 ) diff --git a/src/testsuite.in b/src/testsuite.in index ae07a9d3706a339b46c85b48c3075bc63b4375ca..f6870284a47e1cb96dafa3f056669b45dd788f36 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,5 +1,5 @@ START_MARKER -test_true([["$Id: testsuite.in,v 1.899 2010/09/27 17:06:30 grubba Exp $"]]); +test_true([["$Id$"]]); // This triggered a bug only if run sufficiently early. test_compile_any([[#pike 7.2]]) @@ -286,8 +286,8 @@ test_compile_any([[ dnl number of variables/scope, number of scopes, expect_compiler_error define(test_scopes,[[ test_any([[ - write("Testing scoped variables $1:$2%s...\n", - $3?" expecting a compilation error":""); + log_status("Testing scoped variables $1:$2%s...", + $3?" expecting a compilation error":""); string line = sprintf("#line %d %O\n", __LINE__, __FILE__); string s = "{\n" + (map(indices(allocate($1)), lambda(int no) { @@ -2435,7 +2435,7 @@ string efoo(string e) { void compile_error(string file, int line, string err) { - // write("file: %O, line: %O, err: %O\n", file, line, err); + // log_msg("file: %O, line: %O, err: %O\n", file, line, err); } }; @@ -3256,7 +3256,6 @@ int tests; #define FMT "%d:%d " int maxdepth; -int quiet; string status_prefix=""; class Codec { @@ -3290,8 +3289,8 @@ void low_generate(int depth, if(!(tests & 63)) { __signal_watchdog(); - if(!quiet) - write("\r%s" FMT, status_prefix,maxdepth,tests); + if (_verbose == 1) + log_status("%s" FMT, status_prefix,maxdepth,tests); } string test=code*"\n"+"\n" @@ -3315,27 +3314,27 @@ void low_generate(int depth, if(err) { errors++; - werror("\nTest failed:\n" - "----------------------------------\n" - "%s\n" - "---------------------------------\n" - "expected answer: %O\n" - "Answer received: %O\n",test,ans,res); + log_msg("Test failed:\n" + "----------------------------------\n" + "%s\n" + "---------------------------------\n" + "expected answer: %O\n" + "Answer received: %O\n",test,ans,res); if(!stringp(err) || !has_prefix(err, "Test failed")) { string tmp=master()->describe_backtrace(err); array s=tmp/"\n"; s=s[..20]; - write("%s\n",s*"\n"); + log_msg("%s\n",s*"\n"); } if (res == "None") { // Probable decode error; try to get some debug. catch { - write("Encoding...\n"); + log_msg("Encoding...\n"); string encoded = ((function)encode_value)(tmp, Codec(), 6); - write("Decoding...\n"); + log_msg("Decoding...\n"); tmp = ((function)decode_value)(encoded, Codec(), 6); - write("Strange... No error thrown...\n"); + log_msg("Strange... No error thrown...\n"); }; } return; @@ -3372,9 +3371,7 @@ void low_generate(int depth, array(int) a() { - write("\nTesting vtables and scope access.\n"); - - quiet = !_verbose; + log_status("Testing vtables and scope access.\n"); int total_tests; for(maxdepth=1;maxdepth<9 && !errors;maxdepth++) @@ -3385,15 +3382,12 @@ array(int) a() "X",0); status_prefix+=sprintf(FMT,maxdepth,tests); - if(quiet) - write("%d .. ",maxdepth); - else - write("\r%s",status_prefix); + if (_verbose == 1) + log_status(status_prefix); total_tests+=tests; tests=0; } - write("\n"); return ({ total_tests-errors, errors }); } @@ -5037,7 +5031,7 @@ void log (function f, string msg) if (f == test) msg = "[T] " + msg; else if (f == thread_disabler) msg = " " * 20 + "[D] " + msg; else if (f == mutex_locker) msg = " " * 40 + "[L] " + msg; - write (msg); + log_msg (msg); #endif } @@ -10372,8 +10366,8 @@ int main(int argc, array(string) argv) // watchdog kicks in.. /mast //if (!(i%10)) // __signal_watchdog(); - //if (!(i % 100)) - // write ("%s: %O at %d\n", ctime (time())[..<1], this_thread(), i); + if (!(i % 100)) + log_status ("%s: %O at %d", ctime (time())[..<1], this_thread(), i); } } )->wait();