Revise tools scripts to be python3 compatible on win32 (#4856)
We introduce setup_stdio function to setup stdout/stderr properly. For python <-> python pipe, we always use 'utf8'/'ignore' encoding for not lost characters. For tty <-> python, we using native encoding with xmlcharrefreplace to encode, to preserve maximal information. For python <-> native program, we use naive encoding with 'ignore' to not cause error update_exclude_list with binary mode so that on win32 would not generate \r\n run-test-suite.py: Handling skiplist properly on win32 Fixes #4854 Fixes test262-harness.py complain cannot use a string pattern on a bytes-like object with running test262 with python3 For reading/writing to file, we use 'utf8' /'ignore' encoding for not lost characters. For decoding from process stdout, using native encoding with decoding error ignored for not lost data. Execute commands also ignore errors Fixes #4853 Fixes running test262-esnext failed with installed python3.9 on win32 with space in path Fixes #4852 support both / \ in --test262-test-list arg On win32. python tools/run-tests.py --test262-es2015=update --test262-test-list=built-ins/decodeURI/ python tools/run-tests.py --test262-es2015=update --test262-test-list=built-ins\decodeURI\ should be both valid, currently only --test262-test-list=built-ins\decodeURI\ are valid. Support snapshot-tests-skiplist.txt on win32 by use os.path.normpath Guard run-tests.py with timer. All run-tests.py are finished in 30 minutes in normal situation. May change the timeout by command line option Move Windows CI to github actions Define TERM colors for win32 properly flush stderr.write stdout.write On CI, the stderr are redirect to stdout, and if we don't flush stderr and stdout, The output from stderr/stdout would out of sync. `Testing new Date(-8640000000000000) and fixes date for win32` So that the CI can passed if sys.version_info.major >= 3: remove, as we do not support python2 anymore Fixes compiling warnings/errors for mingw/gcc JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
@@ -97,7 +97,7 @@ jerry_port_source_free (uint8_t *buffer_p)
|
||||
* These functions provide generic implementation for paths and are only enabled when the compiler support weak symbols,
|
||||
* and we are not building for a platform that has platform specific versions.
|
||||
*/
|
||||
#if defined(JERRY_WEAK_SYMBOL_SUPPORT) && !(defined(__unix__) || defined(__APPLE__) || defined(_WIN32))
|
||||
#if !(defined(__unix__) || defined(__APPLE__) || defined(_WIN32))
|
||||
|
||||
jerry_char_t *JERRY_ATTR_WEAK
|
||||
jerry_port_path_normalize (const jerry_char_t *path_p, jerry_size_t path_size)
|
||||
@@ -134,4 +134,4 @@ jerry_port_path_base (const jerry_char_t *path_p)
|
||||
return (jerry_size_t) (basename_p - path_p);
|
||||
} /* jerry_port_path_base */
|
||||
|
||||
#endif /* defined(JERRY_WEAK_SYMBOL_SUPPORT) && !(defined(__unix__) || defined(__APPLE__) || defined(_WIN32)) */
|
||||
#endif /* !(defined(__unix__) || defined(__APPLE__) || defined(_WIN32)) */
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <winbase.h>
|
||||
#include <winnt.h>
|
||||
|
||||
#define UNIX_EPOCH_IN_TICKS 116444736000000000ull /* difference between 1970 and 1601 */
|
||||
#define TICKS_PER_MS 10000ull /* 1 tick is 100 nanoseconds */
|
||||
#define UNIX_EPOCH_IN_TICKS 116444736000000000LL /* difference between 1970 and 1601 */
|
||||
#define TICKS_PER_MS 10000LL /* 1 tick is 100 nanoseconds */
|
||||
|
||||
/*
|
||||
* If you take the limit of SYSTEMTIME (last millisecond in 30827) then you end up with
|
||||
@@ -44,15 +44,9 @@
|
||||
* https://support.microsoft.com/en-us/help/167296/how-to-convert-a-unix-time-t-to-a-win32-filetime-or-systemtime
|
||||
*/
|
||||
static void
|
||||
unix_time_to_filetime (double t, LPFILETIME ft_p)
|
||||
unix_time_to_filetime (LONGLONG t, LPFILETIME ft_p)
|
||||
{
|
||||
LONGLONG ll = (LONGLONG) t * TICKS_PER_MS + UNIX_EPOCH_IN_TICKS;
|
||||
|
||||
/* FILETIME values before the epoch are invalid. */
|
||||
if (ll < 0)
|
||||
{
|
||||
ll = 0;
|
||||
}
|
||||
LONGLONG ll = t * TICKS_PER_MS + UNIX_EPOCH_IN_TICKS;
|
||||
|
||||
ft_p->dwLowDateTime = (DWORD) ll;
|
||||
ft_p->dwHighDateTime = (DWORD) (ll >> 32);
|
||||
@@ -63,13 +57,15 @@ unix_time_to_filetime (double t, LPFILETIME ft_p)
|
||||
*
|
||||
* @return unix time
|
||||
*/
|
||||
static double
|
||||
static LONGLONG
|
||||
filetime_to_unix_time (LPFILETIME ft_p)
|
||||
{
|
||||
ULARGE_INTEGER date;
|
||||
LONGLONG ll;
|
||||
date.HighPart = ft_p->dwHighDateTime;
|
||||
date.LowPart = ft_p->dwLowDateTime;
|
||||
return (double) (((LONGLONG) date.QuadPart - UNIX_EPOCH_IN_TICKS) / TICKS_PER_MS);
|
||||
ll = (LONGLONG) date.QuadPart - UNIX_EPOCH_IN_TICKS;
|
||||
return ll / TICKS_PER_MS;
|
||||
} /* filetime_to_unix_time */
|
||||
|
||||
int32_t
|
||||
@@ -79,6 +75,7 @@ jerry_port_local_tza (double unix_ms)
|
||||
FILETIME local;
|
||||
SYSTEMTIME utc_sys;
|
||||
SYSTEMTIME local_sys;
|
||||
LONGLONG t = (LONGLONG) (unix_ms);
|
||||
|
||||
/*
|
||||
* If the time is earlier than the date 1601-01-02, then always using date 1601-01-02 to
|
||||
@@ -87,23 +84,23 @@ jerry_port_local_tza (double unix_ms)
|
||||
* after converting between local time and utc time, the time may be earlier than 1601-01-01
|
||||
* in UTC time, that exceeds the FILETIME representation range.
|
||||
*/
|
||||
if (unix_ms < (double) UNIX_EPOCH_DATE_1601_01_02)
|
||||
if (t < UNIX_EPOCH_DATE_1601_01_02)
|
||||
{
|
||||
unix_ms = (double) UNIX_EPOCH_DATE_1601_01_02;
|
||||
t = UNIX_EPOCH_DATE_1601_01_02;
|
||||
}
|
||||
|
||||
/* Like above, do not use the last supported day */
|
||||
if (unix_ms > (double) UNIX_EPOCH_DATE_30827_12_29)
|
||||
if (t > UNIX_EPOCH_DATE_30827_12_29)
|
||||
{
|
||||
unix_ms = (double) UNIX_EPOCH_DATE_30827_12_29;
|
||||
t = UNIX_EPOCH_DATE_30827_12_29;
|
||||
}
|
||||
unix_time_to_filetime (unix_ms, &utc);
|
||||
unix_time_to_filetime (t, &utc);
|
||||
|
||||
if (FileTimeToSystemTime (&utc, &utc_sys) && SystemTimeToTzSpecificLocalTime (NULL, &utc_sys, &local_sys)
|
||||
&& SystemTimeToFileTime (&local_sys, &local))
|
||||
{
|
||||
double unix_local = filetime_to_unix_time (&local);
|
||||
return (int32_t) (unix_local - unix_ms);
|
||||
LONGLONG unix_local = filetime_to_unix_time (&local);
|
||||
return (int32_t) (unix_local - t);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -114,7 +111,7 @@ jerry_port_current_time (void)
|
||||
{
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime (&ft);
|
||||
return filetime_to_unix_time (&ft);
|
||||
return (double) filetime_to_unix_time (&ft);
|
||||
} /* jerry_port_current_time */
|
||||
|
||||
#endif /* defined(_WIN32) */
|
||||
|
||||
@@ -25,7 +25,7 @@ jerry_port_path_normalize (const jerry_char_t *path_p, jerry_size_t path_size)
|
||||
{
|
||||
(void) path_size;
|
||||
|
||||
return (jerry_char_t *) _fullpath (NULL, path_p, _MAX_PATH);
|
||||
return (jerry_char_t *) _fullpath (NULL, (const char *) path_p, _MAX_PATH);
|
||||
} /* jerry_port_path_normalize */
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user