Skip to content

ChiefGokhlayeh/tap-consooomer

Repository files navigation

📦 tap-consooomer

That's three o's.

Crate Status Build and Test pre-commit.ci status codecov

Test Anything Protocol (TAP) Consumer for Rust. Capable of parsing TAP14 files into pest tokens.

Usage

Reads a given Test Anything Protocol (TAP) file and prints the JSON-formatted parser result to
stdout. If FILE is omitted, TAP input is read from stdin. Parsing only comences after encountering
an EOF. Only complete TAP files are supported.

USAGE:
    tap [FILE]

ARGS:
    <FILE>
            Path to TAP input file

OPTIONS:
    -h, --help
            Print help information

    -V, --version
            Print version information

Examples

See examples directory for some example TAP logs. To convert them into JSON run:

❯ tap examples/cascading.tap

The TAP log should be transformed as follows:

Input Output
TAP version 14
1..3 # root
ok 1 - i'm in root
# subtest: here begins sub-1
  2..2 # sub-1
  ok 2 - i'm in sub-1
ok 3
{
  "preamble": {
    "version": "14"
  },
  "plan": {
    "first": 1,
    "last": 3,
    "reason": "root"
  },
  "body": [
    {
      "test": {
        "result": true,
        "number": 1,
        "description": "i'm in root",
        "directive": null,
        "yaml": []
      }
    },
    {
      "subtest": {
        "name": "here begins sub-1",
        "plan": {
          "first": 2,
          "last": 2,
          "reason": "sub-1"
        },
        "body": [
          {
            "test": {
              "result": true,
              "number": 2,
              "description": "i'm in sub-1",
              "directive": null,
              "yaml": []
            }
          }
        ]
      }
    },
    {
      "test": {
        "result": true,
        "number": 3,
        "description": null,
        "directive": null,
        "yaml": []
      }
    }
  ]
}

License

Licensed under

Limitations

  • Embedded YAML blocks are parsed into a list of individual yaml lines. These are treated as plain-text and not broken down any further. Use any of your favorite YAML libraries (like serde_yaml) to further parse the embedded YAML block. Any indentation preceding the first element is used as the anchor for the entire YAML block and trimmed off. Any line separators (<LF> or <CR><LF>) at the end of any given yaml line are omitted. Empty or whitespace-only lines inside the embedded YAML block get removed.