Mercurial > projects > dang
changeset 20:95e3940d91d4
Small changes to the text program.
* Sort test-cases by name
* Color output on linux
author | Anders Halager <halager@gmail.com> |
---|---|
date | Fri, 18 Apr 2008 20:28:49 +0200 |
parents | 7e79c42d20f5 |
children | 0fb2d13dce37 |
files | tests/run.d |
diffstat | 1 files changed, 38 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run.d Fri Apr 18 18:24:36 2008 +0200 +++ b/tests/run.d Fri Apr 18 20:28:49 2008 +0200 @@ -1,6 +1,7 @@ module run.d; import tango.io.Stdout, + tango.core.Array, tango.io.FilePath, tango.io.GrowBuffer, tango.io.UnicodeFile, @@ -23,12 +24,15 @@ foreach( path ; cPath.toList((FilePath path, bool isFolder){return isFolder;})) { Stdout(path.name)(":").newline; - foreach( p ; path.toList((FilePath path, bool isFolder) - { - if(path.ext == "d" && path.name[0] != '.') - return true; - return false; - })) + auto paths = path.toList( + (FilePath path, bool isFolder) + { + if(path.ext == "d" && path.name[0] != '.') + return true; + return false; + }); + sort(paths, (FilePath a, FilePath b) { return a.name < b.name; }); + foreach (p ; paths) { auto test = new Test(p); ubyte result = test.run(); @@ -92,7 +96,7 @@ } } - Stdout(" - ")(target.file)(".. "); + Stdout.format(" {,-25}", target.file); process.execute; auto result = process.wait; @@ -106,16 +110,37 @@ result = llvm_process.wait; } - if(result.status == 0) + return resultOf(result.status, mode); + } + + private int resultOf(int status, int mode) + { + char[] good(char[] s) + { + version (Posix) + return "\033[1;32m" ~ s ~ "\033[m"; + else + return s; + } + + char[] bad(char[] s) + { + version (Posix) + return "\033[1;31m" ~ s ~ "\033[m"; + else + return s; + } + + if(status == 0) { if(mode == 0) { - Stdout("SUCCES").newline; + Stdout(good("SUCCES")).newline; return 0; } if(mode == 1) { - Stdout("SUCCES - Unexpected").newline; + Stdout(bad("SUCCES - Unexpected")).newline; return 3; } } @@ -123,15 +148,15 @@ { if(mode == 1) { - Stdout("FAILURE").newline; + Stdout(good("FAILURE")).newline; return 2; } if(mode == 0) { - Stdout("FAILURE - Unexpected").newline; + Stdout(bad("FAILURE - Unexpected")).newline; return 1; } } - } + } }