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

tasks: add --focus parameter to run focused integration tests #167

Merged
merged 2 commits into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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