I'm playing with some changes to swift/stdlib/public/core/Codable.swift, and adding tests for the changes in swift/test/stdlib/CodableTests.swift. I've managed to successfully run the tests with:
However, this takes a long time and there is a ton of output I don't care about. Is there a more concise way to run just the test file I'm working on? I tried a few things with ./swift/utils/run-test, such as:
Thanks. I had not seen that. I'm still a little confused, but I feel like I'm getting closer.
Confusion #1: is there a workflow for doing an incremental build and then running just the test I want? or do I have to keep bounding back and forth between a run-build command and a run-test command that uses --filter?
(More confusions to follow, but I want to do this step by step to make sure I'm on the right track.)
Confusion #1: is there a workflow for doing an incremental build and then running just the test I want? or do I have to keep bounding back and forth between a run-build command and a run-test command that uses --filter ?
Just to give an example, not saying this is the best way to do things, when I am working on something I always:
Create a small targeted test case of my own mytest.swift.
To be clear I only do step 1 once but repeat 2-4 many times, maybe adding additional cases to mytest.swift as I go. To actually run the test, if I am working on diagnostics I can just do:
If you wanted to do 3 and 4 in one step, you could make a script:
#!/bin/bash
# Exit on error
set -e
# Run ninja to build stdlib
ninja -C ../build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64 stdlib
# Run CodableTests.swift
../llvm-project/llvm/utils/lit/lit.py -s -vv ../build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/test-macosx-arm64/stdlib/CodableTests.swift
And if you were working on something else you could change the script to build a different module/run a different test.
Thanks! I’ll try this next time I get a moment to work on it.
Also, is it just me, or does it seem like that workflow is common enough that it should be build into the scripts provided by the repository, in the interest of making it easier for outside/casual contributors?
I’ve found the Getting Started guide to be quite good, but there’s always room for improvement. That said, a script that fits every contributor’s needs might be tricky since workflows can vary quite a bit.
OK! I'm back with a more focused question. I'm trying to spend as little time on the build script stuff as possible so I can actually work on the changes I want to make, at least to get a proof-of-concept put together. To that end, I haven't gone deep on the various guides, but I've skimmed the relevant sections as best I can, and I think I'm at least vaguely moving in the right direction, but please let me know if something I'm doing doesn't make sense!
Here's the script I've put together:
#!/bin/bash
set -e
# build
./swift/utils/build-script --preset=stdlib_DA_standalone,build toolchain_path=/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-03-17-a.xctoolchain/usr/bin
# test
llvm-project/llvm/utils/lit/lit.py -a build/stdlib_DA_standalone/swift-macosx-arm64/test-macosx-arm64/ --filter="CodableTests.swift"
However, that performs a full test, rather than just running CodableTests.swift. I do just want to run CodableTests.swift, rather than writing my own new test file, I think. What am I missing?
if you try running the tests via run-test does that help? e.g. something like:
# use `--build=skip` if you don't want to build first
utils/run-test --lit ../llvm-project/llvm/utils/lit/lit.py \
<build-dir> \
--build=true \
--filter="<tests>"