Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode sys tests and fixes #8135

Merged
merged 77 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
a64b414
sys Unicode test suite
Aurel300 Apr 9, 2019
d2f4461
remove invalid and non-BMP codepoints from the test suite
Aurel300 Apr 10, 2019
4f88ee4
initial FileSystem test (readDirectory)
Aurel300 Apr 10, 2019
3c3b35e
exists, isDirectory, stat
Aurel300 Apr 10, 2019
9ea90c2
setCwd/getCwd tests, a small clean up in the test suite
Aurel300 Apr 10, 2019
f44541f
fix symlinks in test suite
Aurel300 Apr 10, 2019
37bd8bc
fullPath test
Aurel300 Apr 10, 2019
025d44d
test absolutePath
Aurel300 Apr 10, 2019
7926a2b
fix cpp crash (tests still fail)
Aurel300 Apr 10, 2019
3228935
secondary process used to test individual functions
Aurel300 Apr 11, 2019
d6f50fb
change test suite symlink
Aurel300 Apr 11, 2019
d447e72
secondary process test scaffolding, more path tests, some IO tests
Aurel300 Apr 11, 2019
a921fa9
compile utility on cpp
Aurel300 Apr 11, 2019
a0c0c16
stdin, stderr, stdout tests via utility process
Aurel300 Apr 11, 2019
1093c1e
readLine test
Aurel300 Apr 11, 2019
5a39752
posinfos, remove cpp temp fix, fix data.bin
Aurel300 Apr 22, 2019
33d35fc
change all symlinks to utility process
Aurel300 Apr 22, 2019
176ea04
compile utility process on all targets
Aurel300 Apr 22, 2019
46c6de3
fix stdout / stderr write tests
Aurel300 Apr 22, 2019
612faaf
move unicode sequences to separate file
Aurel300 Apr 22, 2019
a322b17
separate args tests from stdout/err tests
Aurel300 Apr 22, 2019
149aca5
print, println
Aurel300 Apr 22, 2019
7a22938
move runUtility to UtilityProcess, getEnv, putEnv, trace tests
Aurel300 Apr 22, 2019
10382db
minor cleanup in utility process
Aurel300 Apr 22, 2019
271a62f
test Sys.environment
Aurel300 Apr 23, 2019
5a69253
test readString, readUntil
Aurel300 Apr 23, 2019
583ccbf
test haxe.io.Path
Aurel300 Apr 23, 2019
fcee980
getString, getContent
Aurel300 Apr 23, 2019
98d6f7f
saveContent
Aurel300 Apr 23, 2019
a902896
write, update, append
Aurel300 Apr 23, 2019
c029574
rename, copy, delteFile, createDirectory, deleteDirectory
Aurel300 Apr 23, 2019
1ac34c9
Unicode paths for File tests
Aurel300 Apr 23, 2019
efc0204
run genTestRes.sh in test setup
Aurel300 Apr 23, 2019
b85d664
spawn processes properly on eval
Aurel300 Apr 24, 2019
a2e1b46
add lua symlinks
Aurel300 Apr 24, 2019
066f923
C# also resolves symlink before programPath
Aurel300 Apr 24, 2019
cbba99e
remove programPath test (does not work with symlinks)
Aurel300 Apr 24, 2019
1a1f4c5
enable sys tests for HashLink
Aurel300 Apr 24, 2019
fede29a
haxe.io.Path use Unicode iterator on UTF-16 platforms
Aurel300 Apr 25, 2019
a0e0454
same but only on hl
Aurel300 Apr 25, 2019
025e12a
re-enable non-BMP, add Unicode filename originally from FileNames.hx
Aurel300 Apr 26, 2019
ab5c3dd
add Unicode test suite files and directories to git
Aurel300 Apr 26, 2019
0549e9e
remove the files (crashes AppVeyor), port bash generation script to p…
Aurel300 May 2, 2019
bb99c4d
test jvm
Aurel300 May 10, 2019
fd4a53a
don't create U+0001 on Windows
Aurel300 May 13, 2019
d40b111
separate filenames and strings in script
Aurel300 May 13, 2019
e093653
fix script
Aurel300 May 14, 2019
5f9c4a5
[skip travis] clean up, use Path.join, temporarily run Unicode tests …
Aurel300 May 14, 2019
0664738
[skip travis] fix Hl binary path
Aurel300 May 14, 2019
d8d9505
[skip travis] sort out Hl paths
Aurel300 May 14, 2019
9aa30a0
[skip travis] fix cleanup, use if utf16 for Path.normalize
Aurel300 May 14, 2019
7424135
[skip travis] expect CRLF on Windows
Aurel300 May 15, 2019
3c022cd
[skip travis] except where it should be LF
Aurel300 May 20, 2019
e0db4d4
[skip travis] fix python println, disable symlink tests on Windows
Aurel300 Jun 5, 2019
480a0a9
[skip travis] set sys encoding to utf-8 in python preamble
Aurel300 Jun 5, 2019
b68860a
use CRLF on php on Windows
Aurel300 Jun 5, 2019
3249df4
[skip travis] try chcp 65001
Aurel300 Jun 5, 2019
b785bff
run Hl on CI properly this time
Aurel300 Jun 5, 2019
755d32d
[skip travis] use binary mode for eval stdout
Aurel300 Jun 5, 2019
0fcf582
set output encoding to UTF-8 on cs
Aurel300 Jun 6, 2019
bc4b81d
[skip travis] set output encoding on java
Aurel300 Jun 6, 2019
0d6804f
move stdout encoding setting to Init class in java and jvm
Aurel300 Jun 6, 2019
34efb27
[skip travis] disable Unicode command line arguments on Java
Aurel300 Jun 6, 2019
2368172
CRLF on Windows on eval
Aurel300 Jun 6, 2019
9168e3c
CRLF on eval trace, disable Unicode arguments on eval on Windows
Aurel300 Jun 6, 2019
bc8080e
also set stderr to UTF-8
Aurel300 Jun 6, 2019
a92afed
add test-res directory to .gitignore
Aurel300 Jun 10, 2019
1c6961b
fix typo in RunCi
Aurel300 Jun 10, 2019
049d2d2
typo fix in genpy
Aurel300 Jun 10, 2019
f57ce56
re-enable sys tests, disable various target-specific tests due to ope…
Aurel300 Jun 10, 2019
e79652d
updated CHANGES.txt
Aurel300 Jun 10, 2019
5970717
add HL to PATH in CI
Aurel300 Jun 10, 2019
34d4435
disable more C++ tests
Aurel300 Jun 10, 2019
8c080f5
[skip travis] expect CRCRLF for now
Aurel300 Jun 10, 2019
c8bd8a4
[skip travis] HL/C++ disable some tests on Windows
Aurel300 Jun 10, 2019
214f4a2
fix conditional compilation
Aurel300 Jun 11, 2019
73add9e
[skip travis] disable args test on HashLink
Aurel300 Jun 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ tests/unit/unit.py.res1.txt
tests/unit/unit.py.res2.bin
tests/sys/bin/
/tests/sys/dump/
/tests/sys/test-res/
tests/optimization/dump/
tests/misc/projects/*/*.n
tests/misc/*/*/*.lua
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ build_script:
- haxelib setup "%HAXELIB_ROOT%"

test_script:
# change codepage to UTF-8
- cmd: chcp 65001
- cd %APPVEYOR_BUILD_FOLDER%/tests/
- haxe -version
- haxe RunCi.hxml
Expand Down
1 change: 1 addition & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
all : fixed `@:allow(package)` allowing too much (#8306)
all : fixed various issues with startIndex handling on String.indexOf and String.lastIndexOf
all : fixed infinite recursion related to printing of objects with circular references (#8113)
sys : fixed various Unicode issues (#8135)
macro : fixed Array.pop handling (#8075)
macro : fixed assertion failure when throwing exception (#8039)
macro : fixed various uncatchable exceptions being thrown
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ and init ctx =
let com = ctx.com in
let classes = ref [([],"Std")] in
try
set_binary_mode_out stdout true;
set_binary_mode_out stderr true;
let xml_out = ref None in
let json_out = ref None in
let swf_header = ref None in
Expand Down
2 changes: 2 additions & 0 deletions src/generators/genjava.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,8 @@ let generate con =
| _ -> ()
with | Not_found -> ()
);
write w "haxe.java.Init.init();";
newline w;
(match gen.gcon.main with
| Some(expr) ->
expr_s w (mk_block expr)
Expand Down
1 change: 1 addition & 0 deletions src/generators/genjvm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,7 @@ class tclass_to_jvm gctx c = object(self)
load();
jm#putstatic ([],"Sys") "_args" (TArray(string_sig,None))
end;
jm#invokestatic (["haxe"; "java"], "Init") "init" (method_sig [] None);
jm#invokestatic jc#get_this_path "main" (method_sig [] None);
jm#return

Expand Down
5 changes: 4 additions & 1 deletion src/generators/genpy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,10 @@ module Generator = struct
let ctx = mk_context com in
Codegen.map_source_header com (fun s -> print ctx "# %s\n# coding: utf-8\n" s);
if has_feature ctx "closure_Array" || has_feature ctx "closure_String" then
spr ctx "from functools import partial as _hx_partial";
spr ctx "from functools import partial as _hx_partial\n";
spr ctx "import sys\n";
spr ctx "if sys.stdout.encoding != 'utf-8':\n sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)\n";
spr ctx "if sys.stderr.encoding != 'utf-8':\n sys.stderr = open(sys.stderr.fileno(), mode='w', encoding='utf8', buffering=1)\n\n";
gen_imports ctx;
gen_resources ctx;
gen_types ctx;
Expand Down
10 changes: 7 additions & 3 deletions src/macro/eval/evalStdLib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,10 @@ module StdLock = struct
)
end

let lineEnd = match Sys.os_type with
| "Win32" | "Cygwin" -> "\r\n"
| _ -> "\n"

module StdLog = struct
let key_fileName = hash "fileName"
let key_lineNumber = hash "lineNumber"
Expand All @@ -1436,15 +1440,15 @@ module StdLog = struct
let trace = vfun2 (fun v infos ->
let s = value_string v in
let s = match infos with
| VNull -> Printf.sprintf "%s\n" s
| VNull -> (Printf.sprintf "%s" s) ^ lineEnd
| _ -> let infos = decode_object infos in
let file_name = decode_string (object_field infos key_fileName) in
let line_number = decode_int (object_field infos key_lineNumber) in
let l = match object_field infos key_customParams with
| VArray va -> s :: (List.map value_string (EvalArray.to_list va))
| _ -> [s]
in
(Printf.sprintf "%s:%i: %s\n" file_name line_number (String.concat "," l)) in
(Printf.sprintf "%s:%i: %s" file_name line_number (String.concat "," l)) ^ lineEnd in
((get_ctx()).curapi.MacroApi.get_com()).Common.print s;
vnull
)
Expand Down Expand Up @@ -2548,7 +2552,7 @@ module StdSys = struct
let println = vfun1 (fun v ->
let ctx = get_ctx() in
let com = ctx.curapi.get_com() in
com.print (value_string v ^ "\n");
com.print (value_string v ^ lineEnd);
vnull
)

Expand Down
1 change: 1 addition & 0 deletions std/cs/Boot.hx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Boot

@:keep public static function init():Void
{
cs.system.Console.OutputEncoding = new cs.system.text.UTF8Encoding();
cs.Lib.applyCultureChanges();
}

Expand Down
5 changes: 5 additions & 0 deletions std/haxe/io/Path.hx
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,13 @@ class Path {
var acc = new StringBuf();
var colon = false;
var slashes = false;
#if utf16
for (c in haxe.iterators.StringIteratorUnicode.unicodeIterator(tmp)) {
switch (c) {
#else
for (i in 0...tmp.length) {
switch (StringTools.fastCodeAt(tmp, i)) {
#end
case ":".code:
acc.add(":");
colon = true;
Expand Down
1 change: 1 addition & 0 deletions std/java/Boot.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import java.internal.Function;
import java.internal.HxObject;
import java.internal.Runtime;
import java.Lib;
import java.Init;
//import java.internal.StringExt;
import java.StdTypes;
import Reflect;
Expand Down
31 changes: 31 additions & 0 deletions std/java/Init.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package java;

@:native("haxe.java.Init") @:keep class Init {
public static function init():Void {
try {
java.lang.System.setOut(new java.io.PrintStream(java.lang.System.out, true, "utf-8"));
java.lang.System.setErr(new java.io.PrintStream(java.lang.System.err, true, "utf-8"));
} catch (e:java.io.UnsupportedEncodingException) {}
}
}
1 change: 1 addition & 0 deletions std/jvm/Jvm.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import jvm.annotation.EnumReflectionInformation;
import jvm.annotation.EnumValueReflectionInformation;
import java.lang.invoke.*;
import java.NativeArray;
import java.Init;
import haxe.ds.Vector;
import haxe.ds.Option;

Expand Down
4 changes: 3 additions & 1 deletion std/php/_std/Sys.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import sys.io.FileInput;
import haxe.SysTools;

@:coreApi class Sys {
static var lineEnd:String = Sys.systemName() == "Windows" ? "\r\n" : "\n";

/** Environment variables set by `Sys.putEnv()` */
static var customEnvVars = new NativeAssocArray<String>();

Expand All @@ -34,7 +36,7 @@ import haxe.SysTools;
}

public static inline function println( v : Dynamic ) : Void {
Global.echo(Std.string(v) + "\n");
Global.echo(Std.string(v) + lineEnd);
}

public static function args() : Array<String> {
Expand Down
3 changes: 2 additions & 1 deletion std/python/Lib.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef PySys = python.lib.Sys;
**/
class Lib {

static var lineEnd:String = Sys.systemName() == "Windows" ? "\r\n" : "\n";
static public var __name__(get, never):String;
static inline function get___name__():String return python.Syntax.code('__name__');

Expand All @@ -54,7 +55,7 @@ class Lib {
**/
public static inline function println(v:Dynamic):Void {
var str = Std.string(v);
printString('$str\n');
printString('$str$lineEnd');
}

/**
Expand Down
29 changes: 23 additions & 6 deletions tests/runci/targets/Hl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@ import runci.System.*;
import runci.Config.*;

class Hl {
static var hlSrc = switch [ci, systemName] {
case [AppVeyor, "Windows"]: "C:\\hashlink";
case _: Path.join([Sys.getEnv("HOME"), "hashlink"]);
};
static var hlBuild = switch [ci, systemName] {
case [AppVeyor, "Windows"]: "C:\\hashlink_build";
case _: Path.join([Sys.getEnv("HOME"), "hashlink_build"]);
};
static var hlBinDir = switch [ci, systemName] {
case [AppVeyor, "Windows"]: "C:\\hashlink_build\\bin";
case _: Path.join([Sys.getEnv("HOME"), "hashlink_build", "bin"]);
};
static var hlBinary = switch [ci, systemName] {
case [AppVeyor, "Windows"]: "C:\\hashlink_build\\bin\\hl";
case _: Path.join([Sys.getEnv("HOME"), "hashlink_build", "bin", "hl"]);
};

static public function getHlDependencies() {
if (commandSucceed("hl", ["--version"])) {
infoMsg('hl has already been installed.');
return;
}
var hlSrc = Path.join([Sys.getEnv("HOME"), "hashlink"]);
runCommand("git", ["clone", "https://github.com/HaxeFoundation/hashlink.git", hlSrc]);

switch (systemName) {
Expand All @@ -23,7 +39,6 @@ class Hl {
//pass
}

var hlBuild = Path.join([Sys.getEnv("HOME"), "hashlink_build"]);
FileSystem.createDirectory(hlBuild);
var generator = systemName == "Windows" ? [] : ["-GNinja"];
runCommand("cmake", generator.concat([
Expand All @@ -45,19 +60,21 @@ class Hl {
"--build", hlBuild
]);

addToPATH(Path.join([hlBuild, "bin"]));
runCommand("hl", ["--version"]);
runCommand(hlBinary, ["--version"]);
addToPATH(hlBinDir);
}

static public function run(args:Array<String>) {
getHlDependencies();
runCommand("haxe", ["compile-hl.hxml"].concat(args));
runCommand("hl", ["bin/unit.hl"]);
runCommand(hlBinary, ["bin/unit.hl"]);

// changeDirectory(threadsDir);
// runCommand("haxe", ["build.hxml", "-hl", "export/threads.hl"]);
// runCommand("hl", ["export/threads.hl"]);

// TODO sys test
changeDirectory(sysDir);
runCommand("haxe", ["compile-hl.hxml"]);
runCommand(hlBinary, ["bin/hl/sys.hl"]);
}
}
5 changes: 5 additions & 0 deletions tests/sys/compile-cpp.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ compile-each.hxml
--next
compile-each.hxml
--main ExitCode
-cpp bin/cpp

--next
compile-each.hxml
--main UtilityProcess
-cpp bin/cpp
5 changes: 5 additions & 0 deletions tests/sys/compile-cs.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ compile-each.hxml
--next
compile-each.hxml
--main ExitCode
-cs bin/cs

--next
compile-each.hxml
--main UtilityProcess
-cs bin/cs
7 changes: 6 additions & 1 deletion tests/sys/compile-hl.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ compile-each.hxml
--next
compile-each.hxml
--main ExitCode
-hl bin/hl/ExitCode.hl
-hl bin/hl/ExitCode.hl

--next
compile-each.hxml
--main UtilityProcess
-hl bin/hl/UtilityProcess.hl
5 changes: 5 additions & 0 deletions tests/sys/compile-java.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ compile-each.hxml
--next
compile-each.hxml
--main ExitCode
-java bin/java

--next
compile-each.hxml
--main UtilityProcess
-java bin/java
6 changes: 6 additions & 0 deletions tests/sys/compile-jvm.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ compile-each.hxml
compile-each.hxml
--main ExitCode
-java bin/jvm
-D jvm

--next
compile-each.hxml
--main UtilityProcess
-java bin/jvm
-D jvm
5 changes: 5 additions & 0 deletions tests/sys/compile-lua.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ compile-each.hxml
compile-each.hxml
--main ExitCode
-lua bin/lua/ExitCode.lua

--next
compile-each.hxml
--main UtilityProcess
-lua bin/lua/UtilityProcess.lua
5 changes: 5 additions & 0 deletions tests/sys/compile-neko.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ compile-each.hxml
# compile-each.hxml
# -main ExitCode
# -neko bin/neko/ExitCode.n

--next
compile-each.hxml
--main UtilityProcess
-neko bin/neko/UtilityProcess.n
7 changes: 6 additions & 1 deletion tests/sys/compile-php.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ compile-each.hxml
--next
compile-each.hxml
--main ExitCode
-php bin/php/ExitCode
-php bin/php/ExitCode

--next
compile-each.hxml
--main UtilityProcess
-php bin/php/UtilityProcess
7 changes: 6 additions & 1 deletion tests/sys/compile-python.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ compile-each.hxml
--next
compile-each.hxml
--main ExitCode
-python bin/python/ExitCode.py
-python bin/python/ExitCode.py

--next
compile-each.hxml
--main UtilityProcess
-python bin/python/UtilityProcess.py
Loading