Swiftpack.co - llvm-swift/FileCheck as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by llvm-swift.
llvm-swift/FileCheck 0.2.6
A standalone Swift version of LLVM's flexible pattern matching file verifier
⭐️ 65
🕓 14 weeks ago
macOS
.package(url: "https://github.com/llvm-swift/FileCheck.git", from: "0.2.6")

FileCheck

Build Status

A standalone Swift version of LLVM's flexible pattern matching file verifier

Introduction

FileCheck is a utility for verifying the contents of two files match (for example, one from standard input, and one residing on disk). This implementation of FileCheck emphasizes its use as a tool for checking output generated by programs against an expected set of strings that can be specified inline next to the print statement that generated it.

The primary API in this package is the fileCheckOutput function, which comes with a number of convenient optional parameters to modify the behavior of the verification process. For example, here is a self-contained test that verifies the output of FizzBuzz:

assert(fileCheckOutput(withPrefixes: ["FIZZBUZZ"]) {
  for i in (1..<10) {
    var out = ""
    if i % 3 == 0 {
      out += "Fizz"
    }
    if i % 5 == 0 {
      out += "Buzz"
    }
    if out.isEmpty {
      out += "\(i)"
    }
    // FIZZBUZZ: 1
    // FIZZBUZZ-NEXT: 2
    // FIZZBUZZ-NEXT: Fizz
    // FIZZBUZZ-NEXT: 4
    // FIZZBUZZ-NEXT: Buzz
    // FIZZBUZZ-NEXT: Fizz
    // FIZZBUZZ-NEXT: 7
    // FIZZBUZZ-NEXT: 8
    // FIZZBUZZ-NEXT: Fizz
    print(out)
  }
})

Executing this test in any file will cause FileCheck to read it in from disk and verify the output of the program against the check-strings in the comments.

Setup

Using The Swift Package Manager

  • Add FileCheck to your Package.swift file's dependencies section:
.package(url: "https://github.com/llvm-swift/FileCheck.git", "0.0.1"..."1.0.0")

Authors

License

This project is released under the MIT license, a copy of which is available in this repo.

GitHub

link
Stars: 65
Last commit: 14 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Release Notes

0.2.6
14 weeks ago

Upgrade Swift Argument Parser to 1.1.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics