| 1 |
import sys.*; |
| 2 |
import sys.io.*; |
| 3 |
import haxe.io.*; |
| 4 |
import haxe.unit.*; |
| 5 |
|
| 6 |
class TestBase extends TestCase { |
| 7 |
static var haxelibPath = FileSystem.fullPath("run.n"); |
| 8 |
public function runHaxelib(args:Array<String>, printProgress = false) { |
| 9 |
var p = new Process("neko", [haxelibPath].concat(args)); |
| 10 |
var stdout = ''; |
| 11 |
var stderr = ''; |
| 12 |
var eofCount = 0; |
| 13 |
var c; |
| 14 |
while (eofCount < 2) { |
| 15 |
eofCount = 0; |
| 16 |
try { |
| 17 |
c = p.stdout.readByte(); |
| 18 |
if (printProgress) Sys.stdout().writeByte(c); |
| 19 |
stdout += String.fromCharCode(c); |
| 20 |
} catch(e:Eof) { |
| 21 |
eofCount++; |
| 22 |
} |
| 23 |
try { |
| 24 |
c = p.stderr.readByte(); |
| 25 |
if (printProgress) Sys.stderr().writeByte(c); |
| 26 |
stderr += String.fromCharCode(c); |
| 27 |
} catch(e:Eof) { |
| 28 |
eofCount++; |
| 29 |
} |
| 30 |
} |
| 31 |
if (printProgress) { |
| 32 |
Sys.stdout().flush(); |
| 33 |
Sys.stderr().flush(); |
| 34 |
} |
| 35 |
var exitCode = p.exitCode(); |
| 36 |
p.close(); |
| 37 |
return { |
| 38 |
stdout: stdout, |
| 39 |
stderr: stderr, |
| 40 |
exitCode: exitCode |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
public function deleteDirectory(dir:String):Void { |
| 45 |
HaxelibTests.deleteDirectory(dir); |
| 46 |
} |
| 47 |
} |