Skip to content

Commit

Permalink
Fix LIT tests on Windows
Browse files Browse the repository at this point in the history
Summary:
This diff includes
* Fixes to LIT tests setup so that most of them success on Windows.
* Disable 6 LIT tests on Windows (which will be worked on later).

Reviewed By: dulinriley

Differential Revision: D17076467

fbshipit-source-id: 7b4ec18baa5b19faa34461f72af110c738f8ee7a
  • Loading branch information
haozhun authored and facebook-github-bot committed Aug 28, 2019
1 parent cf95acb commit f313c1b
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 27 deletions.
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,15 @@ set(HERMES_LIT_TEST_PARAMS
use_flowparser=${HERMES_USE_FLOWPARSER}
jit_enabled=${HERMESVM_JIT}
jit_disassembler_enabled=${HERMESVM_JIT_DISASSEMBLER}
hbc_deltaprep=${HERMES_BINARY_DIR}/bin/hbc-deltaprep
FileCheck=${LLVM_BUILD_DIR}/bin/FileCheck
hermes=${HERMES_BINARY_DIR}/bin/hermes
hermesc=${HERMES_BINARY_DIR}/bin/hermesc
hdb=${HERMES_BINARY_DIR}/bin/hdb
hbcdump=${HERMES_BINARY_DIR}/bin/hbcdump
repl=${HERMES_BINARY_DIR}/bin/hermes-repl
hbc-deltaprep=${HERMES_BINARY_DIR}/bin/hbc-deltaprep
hbc_diff=${HERMES_BINARY_DIR}/bin/hbc-diff
hbc_deltaprep=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-deltaprep
FileCheck=${LLVM_BUILD_DIR}/${CMAKE_CFG_INTDIR}/bin/FileCheck
hermes=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermes
hermesc=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermesc
hdb=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hdb
hbcdump=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbcdump
repl=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermes-repl
hbc-deltaprep=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-deltaprep
hbc_diff=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-diff
build_mode=${HERMES_ASSUMED_BUILD_MODE_IN_LIT_TEST}
exception_on_oom_enabled=${HERMESVM_EXCEPTION_ON_OOM}
serialize_enabled=${HERMESVM_SERIALIZE}
Expand Down
2 changes: 2 additions & 0 deletions test/Driver/driver-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# RUN: sh %s %S %T %hermes
# RUN: sh %s %S %T %hermesc
# TODO(T53144040) Fix LIT tests on Windows
# XFAIL: windows
# shellcheck disable=SC2148

SRCDIR=$1
Expand Down
22 changes: 12 additions & 10 deletions test/Optimizer/cjs/cjs-static-fail-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,57 @@
// file in the root directory of this source tree.
//
// RUN: %hermesc -fstatic-require -commonjs -emit-binary %s 2>&1 > /dev/null | %FileCheck --match-full-lines %s
// TODO(T53144040) Fix LIT tests on Windows
// XFAIL: windows

foo(require);
//CHECK: {{.*}}cjs-static-fail-1.js:8:4: warning: 'require' used as function call argument
//CHECK: {{.*}}cjs-static-fail-1.js:10:4: warning: 'require' used as function call argument
//CHECK-NEXT: foo(require);
//CHECK-NEXT: ^

require(require);
//CHECK: {{.*}}cjs-static-fail-1.js:13:8: warning: 'require' used as function call argument
//CHECK: {{.*}}cjs-static-fail-1.js:15:8: warning: 'require' used as function call argument
//CHECK-NEXT: require(require);
//CHECK-NEXT: ^

new require("a");
//CHECK: {{.*}}cjs-static-fail-1.js:18:12: warning: 'require' used as a constructor
//CHECK: {{.*}}cjs-static-fail-1.js:20:12: warning: 'require' used as a constructor
//CHECK-NEXT: new require("a");
//CHECK-NEXT: ^

this.prop1 = require;
//CHECK: {{.*}}cjs-static-fail-1.js:23:12: warning: 'require' escapes or is modified
//CHECK: {{.*}}cjs-static-fail-1.js:25:12: warning: 'require' escapes or is modified
//CHECK-NEXT: this.prop1 = require;
//CHECK-NEXT: ^

require();
//CHECK: {{.*}}cjs-static-fail-1.js:28:8: warning: require() invoked without arguments
//CHECK: {{.*}}cjs-static-fail-1.js:30:8: warning: require() invoked without arguments
//CHECK-NEXT: require();
//CHECK-NEXT: ^

require("b", "c");
//CHECK: {{.*}}cjs-static-fail-1.js:33:8: warning: Additional require() arguments will be ignored
//CHECK: {{.*}}cjs-static-fail-1.js:35:8: warning: Additional require() arguments will be ignored
//CHECK-NEXT: require("b", "c");
//CHECK-NEXT: ^

require(foo + 1);
//CHECK: {{.*}}cjs-static-fail-1.js:38:8: warning: require() argument cannot be coerced to constant string at compile time
//CHECK: {{.*}}cjs-static-fail-1.js:40:8: warning: require() argument cannot be coerced to constant string at compile time
//CHECK-NEXT: require(foo + 1);
//CHECK-NEXT: ^
//CHECK: {{.*}}cjs-static-fail-1.js:38:9: note: First argument of require()
//CHECK: {{.*}}cjs-static-fail-1.js:40:9: note: First argument of require()
//CHECK-NEXT: require(foo + 1);
//CHECK-NEXT: ^

function func() {
require("c");
var r = require;
//CHECK: {{.*}}cjs-static-fail-1.js:48:11: warning: 'require' is copied to a variable which cannot be analyzed
//CHECK: {{.*}}cjs-static-fail-1.js:50:11: warning: 'require' is copied to a variable which cannot be analyzed
//CHECK-NEXT: var r = require;
//CHECK-NEXT: ^
}

print({}[require]);
//CHECK: {{.*}}cjs-static-fail-1.js:54:9: warning: 'require' is used as a property key and cannot be analyzed
//CHECK: {{.*}}cjs-static-fail-1.js:56:9: warning: 'require' is used as a property key and cannot be analyzed
//CHECK-NEXT: print({}[require]);
//CHECK-NEXT: ^

Expand Down
18 changes: 10 additions & 8 deletions test/Optimizer/cjs/cjs-static-fail-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,44 @@
// file in the root directory of this source tree.
//
// RUN: %hermesc -O -fstatic-require -commonjs -emit-binary %s 2>&1 > /dev/null | %FileCheck --match-full-lines %s
// TODO(T53144040) Fix LIT tests on Windows
// XFAIL: windows

foo(require);
//CHECK: {{.*}}cjs-static-fail-2.js:8:4: warning: 'require' used as function call argument
//CHECK: {{.*}}cjs-static-fail-2.js:10:4: warning: 'require' used as function call argument
//CHECK-NEXT: foo(require);
//CHECK-NEXT: ^

require(require);
//CHECK: {{.*}}cjs-static-fail-2.js:13:8: warning: 'require' used as function call argument
//CHECK: {{.*}}cjs-static-fail-2.js:15:8: warning: 'require' used as function call argument
//CHECK-NEXT: require(require);
//CHECK-NEXT: ^

new require("a");
//CHECK: {{.*}}cjs-static-fail-2.js:18:12: warning: 'require' used as a constructor
//CHECK: {{.*}}cjs-static-fail-2.js:20:12: warning: 'require' used as a constructor
//CHECK-NEXT: new require("a");
//CHECK-NEXT: ^

this.prop1 = require;
//CHECK: {{.*}}cjs-static-fail-2.js:23:12: warning: 'require' escapes or is modified
//CHECK: {{.*}}cjs-static-fail-2.js:25:12: warning: 'require' escapes or is modified
//CHECK-NEXT: this.prop1 = require;
//CHECK-NEXT: ^

require();
//CHECK: {{.*}}cjs-static-fail-2.js:28:8: warning: require() invoked without arguments
//CHECK: {{.*}}cjs-static-fail-2.js:30:8: warning: require() invoked without arguments
//CHECK-NEXT: require();
//CHECK-NEXT: ^

require("b", "c");
//CHECK: {{.*}}cjs-static-fail-2.js:33:8: warning: Additional require() arguments will be ignored
//CHECK: {{.*}}cjs-static-fail-2.js:35:8: warning: Additional require() arguments will be ignored
//CHECK-NEXT: require("b", "c");
//CHECK-NEXT: ^

require(foo + 1);
//CHECK: {{.*}}cjs-static-fail-2.js:38:8: warning: require() argument cannot be coerced to constant string at compile time
//CHECK: {{.*}}cjs-static-fail-2.js:40:8: warning: require() argument cannot be coerced to constant string at compile time
//CHECK-NEXT: require(foo + 1);
//CHECK-NEXT: ^
//CHECK: {{.*}}cjs-static-fail-2.js:38:9: note: First argument of require()
//CHECK: {{.*}}cjs-static-fail-2.js:40:9: note: First argument of require()
//CHECK-NEXT: require(foo + 1);
//CHECK-NEXT: ^

Expand Down
2 changes: 2 additions & 0 deletions test/Optimizer/promotion_on_switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// file in the root directory of this source tree.
//
// RUN: %hermes -target=HBC -emit-binary -O %s > /dev/null
// TODO(T53144040) Fix LIT tests on Windows
// XFAIL: windows

function days_of_the_w_ek(x) {
switch (1) {
Expand Down
2 changes: 2 additions & 0 deletions test/hermes/date-locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ RUN: TZ=EST+5 LC_ALL=tr_TR _HERMES_TEST_LOCALE=tr_TR %hermes -O -target=HBC %s \
RUN: | %FileCheck --match-full-lines -check-prefix TR %s
RUN: TZ=EST+5 %hermes -O -target=HBC %s \
RUN: | %FileCheck --match-full-lines -check-prefix NO %s
TODO(T53144040) Fix LIT tests on Windows
XFAIL: windows
*/
"use strict";

Expand Down
2 changes: 2 additions & 0 deletions test/hermes/string-locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ RUN: LC_ALL=tr_TR.UTF-8 _HERMES_TEST_LOCALE=tr_TR.UTF-8 %hermes -O -target=HBC %
RUN: | %FileCheck --match-full-lines -check-prefix TR %s
RUN: LC_ALL=UTF-8 _HERMES_TEST_LOCALE=UTF-8 %hermes -O -target=HBC %s \
RUN: | %FileCheck --match-full-lines -check-prefix NO %s
TODO(T53144040) Fix LIT tests on Windows
XFAIL: windows
*/
"use strict";

Expand Down
7 changes: 7 additions & 0 deletions test/lit.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import lit
import os
import sys

def isTrue(v):
"""Check whether a string converts to True according to CMake rules"""
Expand Down Expand Up @@ -39,6 +40,12 @@ if lit_config.params["build_mode"] != "opt":
if lit_config.params["build_mode"] == "dbg":
config.available_features.add("slow_debug")

if sys.platform.startswith('cygwin'):
lit_config.fatal('Running Hermes LIT tests in cygwin Python is not '
+ 'supported. Please use regular Python on Windows.')
if os.name == 'nt':
config.available_features.add("windows")

# Note substitutions are applied in order.
# %hermesc must appear before %hermes, or else %hermes will substitute *inside* %hermesc
config.substitutions.append(("%FileCheck", lit_config.params["FileCheck"]))
Expand Down

0 comments on commit f313c1b

Please sign in to comment.