Skip to content

Commit

Permalink
Merge pull request #167 from mull-project/focused-itest
Browse files Browse the repository at this point in the history
 tasks: add --focus parameter to run focused integration tests
  • Loading branch information
stanislaw authored Dec 4, 2021
2 parents 093f30c + 42af296 commit 97c1f62
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
26 changes: 16 additions & 10 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import platform
import re
from typing import Optional

from invoke import task

Expand Down Expand Up @@ -37,61 +38,66 @@ def formatted_command(string):
return re.sub('\\s+', ' ', string).strip()


def run_lit_tests(c, filecheck_exec, filecheck_tester_exec, llvm_only):
def run_lit_tests(
c, filecheck_exec, filecheck_tester_exec, focus: Optional[str], llvm_only
):
assert c
assert filecheck_exec
assert llvm_only is not None

cwd = os.getcwd()

llvm_only_value = "1" if llvm_only else ""
focus_or_none = f"--filter {focus}" if focus else ""

command = formatted_command("""
lit
--param REAL_ONLY={llvm_only_value}
--param FILECHECK_EXEC="{filecheck_exec}"
--param FILECHECK_TESTER_EXEC="{filecheck_tester_exec}"
-v
{focus_or_none}
{cwd}/tests/integration
""").format(cwd=cwd,
filecheck_exec=filecheck_exec,
filecheck_tester_exec=filecheck_tester_exec,
focus_or_none=focus_or_none,
llvm_only_value=llvm_only_value)

print(command)
c.run("{}".format(command))


@task
def test_filecheck_llvm(c):
def test_filecheck_llvm(c, focus=None):
filecheck_llvm_8_exec = get_filecheck_llvm_path(FILECHECK_LLVM_8_EXEC)
filecheck_llvm_9_exec = get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC)
filecheck_tester_exec = get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC)

# run_lit_tests(c, filecheck_llvm_8_exec, filecheck_tester_exec, True)
run_lit_tests(c, filecheck_llvm_9_exec, filecheck_tester_exec, True)
run_lit_tests(c, filecheck_llvm_9_exec, filecheck_tester_exec, focus, True)


@task
def test_filecheck_py_using_file_check_llvm_tester(c):
def test_filecheck_py_using_file_check_llvm_tester(c, focus=None):
filecheck_exec = get_filecheck_py_exec()
filecheck_tester_exec = get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC)

run_lit_tests(c, filecheck_exec, filecheck_tester_exec, False)
run_lit_tests(c, filecheck_exec, filecheck_tester_exec, focus, False)


@task
def test_filecheck_py_using_filecheck_py_tester(c):
def test_filecheck_py_using_filecheck_py_tester(c, focus=None):
filecheck_exec = get_filecheck_py_exec()
filecheck_tester_exec = filecheck_exec

run_lit_tests(c, filecheck_exec, filecheck_tester_exec, False)
run_lit_tests(c, filecheck_exec, filecheck_tester_exec, focus, False)


@task
def test(c):
test_filecheck_llvm(c)
test_filecheck_py_using_file_check_llvm_tester(c)
def test(c, focus=None):
test_filecheck_llvm(c, focus)
test_filecheck_py_using_file_check_llvm_tester(c, focus)


@task
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
; RUN: gcc "%s" -o %S/hello-world-1 && %S/hello-world-1 | filecheck %s
; RUN: gcc "%s" -o %S/hello-world-1 && %S/hello-world-1 | %FILECHECK_EXEC %s
; CHECK: Hello world
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
; RUN: gcc "%s" -o %S/hello-world-2 && %S/hello-world-2 | filecheck %s; test $? = 1
; RUN: gcc "%s" -o %S/hello-world-2 && %S/hello-world-2 | %FILECHECK_EXEC %s; test $? = 1
; CHECK: Wrong line
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
RUN: echo "Hello world" | filecheck %s
RUN: echo "Hello world" | %FILECHECK_EXEC %s
CHECK: Hello world

0 comments on commit 97c1f62

Please sign in to comment.