Swiftpack.co - Package - llvm-swift/FileCheck

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: 58

Used By

Total: 0

Releases

0.2.4 - 2020-05-21 07:07:40

  • Removed compilation warning from Swift 5.2.

0.2.3 - 2019-11-26 03:41:41

  • Fixed a bug where TTY devices aren't receiving colored output as intended.

0.2.2 - 2019-11-25 02:59:42

  • FileCheck now requires Xcode 11.2+ and Swift 5.1 to build.

0.2.1 - 2019-10-17 05:36:21

  • Error messages no longer include ANSI color code for non-terminal devices.

0.2.0 - 2019-06-26 20:53:31

  • Declare a new filecheck standalone tool

0.1.0 - 2019-03-26 01:24:17

  • FileCheck now requires Xcode 10.2+ and Swift 5 to build.

- 2018-09-18 16:09:13

  • FileCheck now requires Xcode 10 and Swift 4.2 to build

0.0.7 - 2018-04-12 05:46:10

  • Resolve multiple invalid buffer access conditions caught by ASAN
  • Dramatically speed up the Levenstein Distance computation

- 2018-03-01 08:10:47

  • Add scoped variables.
  • Fix a crash caused by incorrect bounds while parsing CHECK patterns.

0.0.5 - 2017-11-20 18:18:16

  • Massive improvements to the Levenstein distance algorithm powering diagnostic recommendations.

- 2017-11-02 02:18:49

Update for Xcode 9.1

0.0.3 - 2017-09-22 01:58:39

Restore build integrity across platforms.

Swift 4 - 2017-09-20 17:14:36

- 2017-03-12 18:28:44