# Need a workflow advice

**URL:** <https://forums.swift.org/t/need-a-workflow-advice/12536>\
**Category:** Compiler\
**Created:** [May 10, 2018, 10:00am UTC](https://forums.swift.org/t/need-a-workflow-advice/12536 "2018-05-10T10:00:33Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![codafi](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/codafi/32/791_2.png) [@codafi](https://forums.swift.org/u/codafi)\
**Post date:** [May 12, 2018, 3:13am UTC](https://forums.swift.org/t/need-a-workflow-advice/12536/14 "2018-05-12T03:13:37Z")

</div>

You absolutely do not need a toolchain to test!

You say that you have a Ninja-DebugAssert build and an Xcode-RelWithDebInfoAssert+swift-DebugAssert build, so (assuming you have a mac - you can replace the `macosx-x86_64` with the arch of your choice as long as you've got it built)

# Ninja-DebugAssert

```swift
$ cd ./build/Ninja-DebugAssert/swift-macosx-x86_64/ # Commands Assume You Run Me First!

```

Full build

```swift
$ ninja

```

Incremental build

```swift
$ ninja <target1> <target2> ... <targetn> # Use `ninja -t targets` to list these 

```

Running Swift

```swift
$ ./bin/swift /Path/To/test.swift

```

Getting a Development REPL

```swift
$ ./bin/swift

```

## Running Tests

```swift
$ cd /Path/To/Swift/Source/.. # Commands Assume You Run Me First! (Note the ..)

```

Running All The Tests

```swift
$ ./llvm/utils/lit/lit.py ./build/Ninja-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/

```

Running The Tests Without Filling Your Shell

```swift
$ ./llvm/utils/lit/lit.py -sv ./build/Ninja-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/

```

Oh Crap, I Broke This Test And Need To See All The Output

```swift
$ ./llvm/utils/lit/lit.py -a ./build/Ninja-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Path/To/Test.swift

```

Oh Crap, I Broke The Validation Tests (Wait, We Have Validation Tests??)

```swift
$ ./llvm/utils/lit/lit.py ./build/Ninja-DebugAssert/swift-macosx-x86_64/validation-test-macosx-x86_64/

```

Why Am I Running All These Tests, Can't I Just Run A Subset?

```swift
$ ./llvm/utils/lit/lit.py ./build/Ninja-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/ --filter=<REGEX>

```

_Caveat: Lit drops multiple --filter flags and only takes the last one_

# Writing Tests

```swift
$ cd /Path/To/Swift/Source/ # Commands Assume You Run Me First!

```

_Open an existing file under `./test`. If you really can't find one/want to play around, write one and put it in the right folder._

RUN Lines: Tell Lit what to do (they're comments so Swiftc doesn't barf - don't name anything `RUN:` or `REQUIRES:`, etc. or you will have a bad time)

```swift
// RUN: <shell commands & Lit Substitutions>
// RUN: <more shell commands & Lit Substitutions>
// ...
// RUN: etc.
// See ./test/lit.cfg (look for config.substitutions)

```

e.g.

```swift
// These Are Equivalent (Now you see why we use the substitutions)
// RUN: %target-typecheck-verify-swift
// RUN: /build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swiftc -frontend -target x86_64-apple-macosx10.9 -module-cache-path '/build/Ninja-DebugAssert/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache' -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -swift-version 3 -typecheck -verify -disable-objc-attr-requires-foundation-module /swift/test/Path/to/file.swift -module-name MyModule

```

REQUIRES Lines: Sometimes you've gotta gate your test

```swift
// REQUIRES: objc_interop # I need Objective-C
// REQUIRES: executable_test # Test needs to build and run a binary 
// REQUIRES: OS=macosx # Only macOS
// REQUIRES: CPU=x86_64 # Only Intel x86_64
// REQUIRES: rdar777777 # I'm disabling/need to fix this test later, sorry, here's a radar number
// See ./test/lit.cfg for more

```

---

_[View the full topic](https://forums.swift.org/t/need-a-workflow-advice/12536)._
