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

[libc] integration test outputs header in build #98385

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions libc/newhdrgen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
if(LLVM_LIBC_FULL_BUILD)

enable_testing()

set(NEWHDGEN_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
set(TEST_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/newhdrgen/output)

add_test(
NAME newhdrgen_integration_test
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} python3 ${NEWHDGEN_TESTS_DIR}/test_integration.py
COMMAND python3 ${NEWHDGEN_TESTS_DIR}/test_integration.py --output_dir ${TEST_OUTPUT_DIR}
)

add_custom_target(check-newhdrgen
COMMAND ${CMAKE_CTEST_COMMAND} -R newhdrgen_integration_test
COMMAND ${CMAKE_CTEST_COMMAND} -R newhdrgen_integration_test --output-on-failure
)

message(STATUS "Integration test for newhdrgen added.")
Expand Down
42 changes: 0 additions & 42 deletions libc/newhdrgen/tests/output/test_small.h

This file was deleted.

23 changes: 13 additions & 10 deletions libc/newhdrgen/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@
from pathlib import Path
import os
import argparse
import sys


class TestHeaderGenIntegration(unittest.TestCase):
def setUp(self):
parser = argparse.ArgumentParser(
description="TestHeaderGenIntegration arguments"
)
parser.add_argument(
"--output_dir", type=str, help="Output directory for generated headers"
)
args, _ = parser.parse_known_args()
output_dir_env = os.getenv("TEST_OUTPUT_DIR")

self.output_dir = Path(
args.output_dir
if args.output_dir
else output_dir_env if output_dir_env else "libc/newhdrgen/tests/output"
output_dir_env if output_dir_env else "libc/newhdrgen/tests/output"
)

self.maxDiff = None
Expand Down Expand Up @@ -71,4 +63,15 @@ def test_generate_header(self):


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="TestHeaderGenIntegration arguments")
parser.add_argument(
"--output_dir", type=str, help="Output directory for generated headers"
)
args, remaining_argv = parser.parse_known_args()

if args.output_dir:
os.environ["TEST_OUTPUT_DIR"] = args.output_dir
aaryanshukla marked this conversation as resolved.
Show resolved Hide resolved

sys.argv[1:] = remaining_argv

unittest.main()
Loading