Ver Fonte

fixed Process (at least my small test is working)

frabbit há 11 anos atrás
pai
commit
fd763b0b2a

+ 1 - 3
std/haxe/io/Input.hx

@@ -129,10 +129,8 @@ class Input {
 		var last : Int;
 		var last : Int;
 		var s;
 		var s;
 		try {
 		try {
-			while( (last = readByte()) != 10 ) {
-				trace("read" + last);
+			while( (last = readByte()) != 10 )
 				buf.addChar( last );
 				buf.addChar( last );
-			}
 			s = buf.toString();
 			s = buf.toString();
 			if( s.charCodeAt(s.length-1) == 13 ) s = s.substr(0,-1);
 			if( s.charCodeAt(s.length-1) == 13 ) s = s.substr(0,-1);
 		} catch( e : Eof ) {
 		} catch( e : Eof ) {

+ 3 - 1
std/python/_std/sys/io/Process.hx

@@ -14,7 +14,9 @@ class Process {
 
 
 	public function new( cmd : String, args : Array<String> ) : Void {
 	public function new( cmd : String, args : Array<String> ) : Void {
 
 
-		p = Popen.create(args, { bufsize : 1, executable : cmd, stdin : Subprocess.PIPE, stdout: Subprocess.PIPE, stderr : Subprocess.PIPE });
+		p = Popen.create([cmd].concat(args), { stdin : Subprocess.PIPE, stdout: Subprocess.PIPE, stderr : Subprocess.PIPE });
+
+
 		this.stdout = new FileInput (cast p.stdout);
 		this.stdout = new FileInput (cast p.stdout);
 		this.stderr = new FileInput (cast p.stderr);
 		this.stderr = new FileInput (cast p.stderr);
 		this.stdin =  new FileOutput(cast p.stdin);
 		this.stdin =  new FileOutput(cast p.stdin);

+ 1 - 1
std/python/io/NativeInput.hx

@@ -38,7 +38,7 @@ class NativeInput extends Input{
 	{
 	{
 
 
 		var ret = stream.read(1);
 		var ret = stream.read(1);
-		trace(ret);
+
 		if (ret.length == 0) throw new Eof();
 		if (ret.length == 0) throw new Eof();
 
 
 		return ret.get(0);
 		return ret.get(0);

+ 14 - 0
tests/unit/TestPython.hx

@@ -1,5 +1,8 @@
 package unit;
 package unit;
 
 
+import sys.io.File;
+import sys.io.Process;
+
 private typedef T = {
 private typedef T = {
 	var value:Int;
 	var value:Int;
 	@:optional var maybeValue:Int;
 	@:optional var maybeValue:Int;
@@ -62,4 +65,15 @@ class TestPython extends Test {
 		eq("12a", skip(12, "a"));
 		eq("12a", skip(12, "a"));
 		eq("1a", skip("a"));
 		eq("1a", skip("a"));
 	}
 	}
+
+	/*
+	function testSys () {
+
+		var p = new Process("/bin/ls", ["-l"]);
+
+		trace(p.stdout.readLine());
+		trace(p.stdout.readLine());
+	}
+	*/
+
 }
 }