Skip to content

Commit 8fa533a

Browse files
authored
Merge pull request #1463 from Thirumalai-Shaktivel/fix_carriage_return
Enable `run_tests` in Windows CI
2 parents 9417d7e + ad6b324 commit 8fa533a

File tree

6 files changed

+31
-11
lines changed

6 files changed

+31
-11
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.py -text

ci/test.xsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ src/bin/lpython --show-ast tests/doconcurrentloop_01.py
1515
src/bin/lpython --show-asr tests/doconcurrentloop_01.py
1616
src/bin/lpython --show-cpp tests/doconcurrentloop_01.py
1717

18-
if $WIN != "1":
18+
if $WIN == "1":
19+
python run_tests.py --skip-run-with-dbg --no-color
20+
else:
1921
python run_tests.py
2022
cd integration_tests
2123
python run_tests.py -j16 -b llvm cpython c wasm

run_tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def single_test(test, verbose, no_llvm, skip_run_with_dbg, update_reference,
13-
specific_backends=None, excluded_backends=None):
13+
no_color, specific_backends=None, excluded_backends=None):
1414
filename = test["filename"]
1515
def is_included(backend):
1616
return test.get(backend, False) \
@@ -36,7 +36,10 @@ def is_included(backend):
3636
if pass_ and (pass_ not in ["do_loops", "global_stmts"] and
3737
pass_ not in optimization_passes):
3838
raise Exception(f"Unknown pass: {pass_}")
39-
log.debug(f"{color(style.bold)} START TEST: {color(style.reset)} {filename}")
39+
if no_color:
40+
log.debug(f" START TEST: {filename}")
41+
else:
42+
log.debug(f"{color(style.bold)} START TEST: {color(style.reset)} {filename}")
4043

4144
extra_args = f"--no-error-banner {show_verbose}"
4245

src/bin/lpython.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ int link_executable(const std::vector<std::string> &infiles,
10671067
for (auto &s : infiles) {
10681068
cmd += s + " ";
10691069
}
1070-
cmd += runtime_library_dir + "\\lpython_runtime_static.lib";
1070+
cmd += runtime_library_dir + "\\lpython_runtime_static.lib > NUL";
10711071
int err = system(cmd.c_str());
10721072
if (err) {
10731073
std::cout << "The command '" + cmd + "' failed." << std::endl;

src/libasr/compiler_tester/tester.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
SRC_DIR = os.path.dirname(LIBASR_DIR)
3030
ROOT_DIR = os.path.dirname(SRC_DIR)
3131

32+
no_color = False
3233

3334
class RunException(Exception):
3435
pass
@@ -329,7 +330,10 @@ def run_test(testname, basename, cmd, infile, update_reference=False,
329330
raise RunException(
330331
"Testing with reference output failed." +
331332
full_err_str)
332-
log.debug(s + " " + check())
333+
if no_color:
334+
log.debug(s + " PASS")
335+
else:
336+
log.debug(s + " " + check())
333337

334338

335339
def tester_main(compiler, single_test):
@@ -358,6 +362,8 @@ def tester_main(compiler, single_test):
358362
help="Skip runtime tests with debugging information enabled")
359363
parser.add_argument("-s", "--sequential", action="store_true",
360364
help="Run all tests sequentially")
365+
parser.add_argument("--no-color", action="store_true",
366+
help="Turn off colored tests output")
361367
args = parser.parse_args()
362368
update_reference = args.update
363369
list_tests = args.list
@@ -374,6 +380,8 @@ def tester_main(compiler, single_test):
374380
verbose = args.verbose
375381
no_llvm = args.no_llvm
376382
skip_run_with_dbg = args.skip_run_with_dbg
383+
global no_color
384+
no_color = args.no_color
377385

378386
# So that the tests find the `lcompiler` executable
379387
os.environ["PATH"] = os.path.join(SRC_DIR, "bin") \
@@ -401,7 +409,8 @@ def tester_main(compiler, single_test):
401409
excluded_backends=excluded_backends,
402410
verbose=verbose,
403411
no_llvm=no_llvm,
404-
skip_run_with_dbg=skip_run_with_dbg)
412+
skip_run_with_dbg=skip_run_with_dbg,
413+
no_color=no_color)
405414
# run in parallel
406415
else:
407416
single_tester_partial_args = partial(
@@ -411,7 +420,8 @@ def tester_main(compiler, single_test):
411420
excluded_backends=excluded_backends,
412421
verbose=verbose,
413422
no_llvm=no_llvm,
414-
skip_run_with_dbg=skip_run_with_dbg)
423+
skip_run_with_dbg=skip_run_with_dbg,
424+
no_color=no_color)
415425
with ThreadPoolExecutor() as ex:
416426
futures = ex.map(single_tester_partial_args, filtered_tests)
417427
for f in futures:
@@ -423,5 +433,9 @@ def tester_main(compiler, single_test):
423433
if update_reference:
424434
log.info("Test references updated.")
425435
else:
426-
log.info(
427-
f"{(color(fg.green) + color(style.bold))}TESTS PASSED{color(fg.reset) + color(style.reset)}")
436+
if no_color:
437+
log.info("TESTS PASSED")
438+
else:
439+
log.info(
440+
f"{(color(fg.green) + color(style.bold))}TESTS PASSED"
441+
f"{color(fg.reset) + color(style.reset)}")

src/lpython/parser/tokenizer.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ int Tokenizer::lex(Allocator &al, YYSTYPE &yylval, Location &loc, diag::Diagnost
264264
re2c:define:YYCTYPE = "unsigned char";
265265
266266
end = "\x00";
267-
whitespace = [ \t\v\r]+;
268-
newline = "\n";
267+
whitespace = [ \t\v]+;
268+
newline = "\n" | "\r\n";
269269
digit = [0-9];
270270
int_oct = "0"[oO]([0-7] | "_" [0-7])+;
271271
int_bin = "0"[bB]([01] | "_" [01])+;

0 commit comments

Comments
 (0)