How to run bindings test

Hi there,

Reading through the MLIR bindings and the following FileCheck test exists

# RUN: %PYTHON %s | mlir-opt -split-input-file | FileCheck

# TODO: Move to a test utility class once any of this actually exists.
def print_module(f):
  m = f()
  print("// -----")
  print("// TEST_FUNCTION:", f.__name__)
  return f

def create_my_op():
  m =
  builder = m.new_op_builder()
  # CHECK: mydialect.my_operation ...
  return m

How do I go about running this? I tried just running the section at the start (%PYTHON %s | mlir-opt -split-input-file | FileCheck), but get

$ %PYTHON %s | mlir-opt -split-input-file | FileCheck
<check-file> not specified
%PYTHON: command not found


Use llvm-lit. For example, $LLVM_DIR/build/bin/llvm-lit mlir/test/python/ It performs the substitution of %PYTHON according to the configuration that you can find in llvm-project/ at main · llvm/llvm-project · GitHub.

That’s super helpful thank you!

I ran the example syntax you mentioned above, however the test fails:

-- Testing: 1 tests, 1 workers --
FAIL: MLIR :: python/ (1 of 1)
Failed Tests (1):
  MLIR :: python/

Testing Time: 0.58s
  Failed: 1

Any ideas why?

Never mind, running the test with -v to show a larger description of the error fixed it:)

Thanks for your help!

1 Like