Please tell me how to test a file inside test/SILGen

Hello, I'm Kobe from South Korea, studying Swift and iOS.

I would like to run and test the swift/test/SILGen/closure.swift file.

I am curious about how I can test this file.

Thank you.

With sincerity, Kobe from Korea.

Swift uses a test-suite utility from LLVM called lit. The build sets things up so that lit will pretend that the test directories in your source tree are overlaid on top of the corresponding directories in your build tree. That is, you can just pass lit the path of a "file" in your build tree, and it will actually look for that test file in your source tree.

So:

  • You need to have already built Swift for testing.
  • You need to know your way around the build directories. Assume you've checked out Swift into a directory called $srcroot; this is the directory with the swift, llvm-project, etc. subdirectories. There should be a subdirectory something like build/Ninja-ReleaseAssert/swift-macosx-x86_64 inside that; it might be slightly different depending on your system and how you've configured your build. That directory is your Swift build directory.
  • You need to have set up an alias for lit. This will be something like alias lit='$srcroot/llvm-project/llvm/utils/lit/lit.py'.
  • You need to cd into your Swift build directory.
  • You should then be able to just run lit test-macosx-x86_64/SILGen/closure.swift.
1 Like

Hello John, I'm Kobe.

I'm profoundly touched by your kind and detailed explanation.

Furthermore, I am delighted that your response resolved my issue.

I didn't expect such a detailed and friendly answer, but your genuine and comprehensive response has made my journey in studying iOS and Swift here a joyous experience.

I sincerely wish every day brings you happiness.

Thank you very much for your response.

With heartfelt thanks from Korea.

-Kobe-

1 Like