Skip to content

Commit

Permalink
add project_src_dir so tests work with both bazel and cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Oct 31, 2023
1 parent d39dcdb commit 1902439
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tests/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@
+ ":"
+ os.environ["PATH"]
)

substitutions = {
"%project_source_dir": runfiles_dir.joinpath(Path('mlir_tutorial')),
}
config.substitutions.extend(substitutions.items())
3 changes: 2 additions & 1 deletion tests/lit.cmake.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

config.substitutions.append(("%PATH%", config.environment["PATH"]))
config.substitutions.append(("%shlibext", config.llvm_shlib_ext))
config.substitutions.append(("%project_source_dir", config.project_source_dir))

llvm_config.with_system_environment(["HOME", "INCLUDE", "LIB", "TMP", "TEMP"])

Expand All @@ -49,4 +50,4 @@
"tutorial-opt"
]

llvm_config.add_tool_substitutions(tools, tool_dirs)
llvm_config.add_tool_substitutions(tools, tool_dirs)
2 changes: 1 addition & 1 deletion tests/lit.cmake.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import lit.llvm
lit.llvm.initialize(lit_config, config)

# Let the main config do the real work.
lit_config.load_config(config, "@PROJECT_SOURCE_DIR@/tests/lit.cmake.cfg.py")
lit_config.load_config(config, "@PROJECT_SOURCE_DIR@/tests/lit.cmake.cfg.py")
2 changes: 1 addition & 1 deletion tests/poly_to_llvm.mlir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: tutorial-opt --poly-to-llvm %s | mlir-translate --mlir-to-llvmir | llc --relocation-model=pic -filetype=obj > %t
// RUN: clang -c poly_to_llvm_main.c
// RUN: clang -c %project_source_dir/tests/poly_to_llvm_main.c
// RUN: clang poly_to_llvm_main.o %t -o a.out
// RUN: ./a.out | FileCheck %s

Expand Down
2 changes: 1 addition & 1 deletion tests/poly_to_llvm_eval.mlir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: tutorial-opt --poly-to-llvm %s | mlir-translate --mlir-to-llvmir | llc --relocation-model=pic -filetype=obj > %t
// RUN: clang -c poly_to_llvm_main.c
// RUN: clang -c %project_source_dir/tests/poly_to_llvm_main.c
// RUN: clang poly_to_llvm_main.o %t -o eval_test.out
// RUN: ./eval_test.out | FileCheck %s

Expand Down

0 comments on commit 1902439

Please sign in to comment.