├── README ├── draft-vaidya-test-anything-protocol-00.xml └── output └── draft-vaidya-test-anything-protocol-00.txt /README: -------------------------------------------------------------------------------- 1 | This is an attempt to write an Internet-Draft level 2 | document, setting out the Test Anything Protocol (TAP) 3 | as a language for storing, recording and summarizing 4 | automated testing results. 5 | 6 | For more details, please see: 7 | - http://www.testanything.org/ (TAP website) 8 | - http://testanything.org/wiki/index.php/TAP_at_IETF:_Draft_Standard 9 | - https://www.ietf.org/mailman/listinfo/tap (mailing list) 10 | -------------------------------------------------------------------------------- /draft-vaidya-test-anything-protocol-00.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 10 | ]> 11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | The Test Anything Protocol (TAP) 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | The Test Anything Protocol (TAP) is a protocol to allow 39 | communication between unit tests and a test harness. It allows 40 | individual tests (TAP producers) to communicate test results to the 41 | testing harness in a language-agnostic way. Tests can indicate 42 | success, failure, as well as mark tests as unimplemented or 43 | skipped, and to provide additional information to aid in debugging 44 | of failed tests. Unlike other testing systems, it can indicate 45 | missing tests and duplicated tests. 46 | 47 | 48 | 49 | This specification defines TAP version 13. 50 | 51 | 52 | 53 | 54 | 55 |
56 | 57 | The Test Anything Protocol (TAP) describes a standard format for 58 | testing suites to use. This format provides both human and 59 | machine-readable information on which tests were run, whether they 60 | were successful or failed, as well as other information which might 61 | be useful in tracing the cause of the failure. Being 62 | machine-readable allows this information to be easily parsed by an 63 | automated testing harness. Test results may then be summarized and 64 | analyzed. Being human-readable allows the results of a testing 65 | system to be read manually; this is useful for quickly determining 66 | whether individual tests pass and to aid in debugging the test 67 | system itself. 68 | 69 | 70 | 71 | TAP has been used by the Perl interpreter's test suite since 1987. 72 | 73 | 74 |
75 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", 76 | "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", 77 | and "OPTIONAL" in this document are to be interpreted as 78 | described in . 79 | 80 | 81 | The grammatical rules in this document are following ABNF and 82 | are to be interpreted as described in . 83 | 84 |
85 |
86 | 87 |
88 | 89 | 90 | 91 | 92 | A piece of software which determines if a particular facility or 93 | component is functional. 94 | 95 | 96 | 97 | 98 | The encoding in TAP of the result of a single test. It may have 99 | exactly one TAP result directive. 100 | 101 | 102 | 103 | 104 | Zero or more test results with exactly one plan. A test set can 105 | be determined to have failed or passed. 106 | 107 | 108 | 109 | 110 | A collection of test sets. 111 | 112 | 113 | 114 | 115 | One test set which parses correctly as defined in this 116 | document. Future expansion may allow multiple test sets to be 117 | contained in a single TAP document, allowing an entire test 118 | suite to be stored as a single TAP document. 119 | 120 | 121 | 122 | 123 | The number of tests which are expected to pass in a single test 124 | set. 125 | 126 | 127 | 128 | 129 | A directive changes the meaning of a test result; it is 130 | commonly used to indicate that a failing test should be 131 | reported as passing (TODO) or that a passing test should be 132 | tagged as suspicious (SKIP). 133 | 134 | 135 | 136 | 137 | A reason explains why a directive was necessary. 138 | 139 | 140 | 141 | 142 | A description says what a test result is testing. 143 | 144 | 145 | 146 | 147 | A producer is a thing which can generate a valid TAP document. 148 | 149 | 150 | 151 | 152 | A consumer is a thing which can parse and interpret a TAP 153 | document. 154 | 155 | 156 | 157 | 158 | A filter a piece of software which consumes a TAP document, and 159 | produces a new TAP document based in some way on the TAP input. 160 | For example, it can reproduce the TAP document exactly, 161 | normalize the formatting, combine multiple documents, or 162 | summarize the result of tests as a new TAP document. 163 | 164 | 165 | 166 |
167 | 168 |
169 | 170 | A TAP document might exist as a file, data stream, encoded in 171 | another medium (stored in a PDF file, for instance) or in any other 172 | form which can be parsed as described below. For maximum 173 | compatibility, it may be produced by any TAP producer, and must 174 | then be consumable by any TAP consumer. 175 | 176 | 177 | 178 | One example system of producers and consumers is the 179 | Test::More/Test::Harness system in Perl testing. In this system, 180 | test producers are executable Perl scripts with a '.t' extension, 181 | collected in a number of folders, which themselves use the 182 | Test::More library to simplify testing. These scripts can be 183 | executed individually, and emit TAP documents on standard output. 184 | 185 | 186 | 187 | A TAP consumer, such as the Perl module TAP::Parser, can interpret 188 | the output of a TAP producer to determine how many tests were run, 189 | which tests succeeded, and which diagnostic information might be 190 | usefully reported to the user. 191 | 192 | 193 | 194 | Note that these two processes are often decoupled. The TAP document 195 | emitted by the TAP producer can be stored before being interpreted 196 | by the TAP parser; this allows all diagnostic and testing 197 | information to be stored for later analysis and usage. The TAP 198 | document might be generated on one server, then downloaded to 199 | another before being processed. A single TAP parser can be used to 200 | process files in all these cases, illustrating TAP's utility as a 201 | cross-language, cross-environment tool. 202 | 203 | 204 | 205 | The complete flow in this system can look something like this: 206 | 207 | 208 |
209 | | Storage | +--> | Formatted Output | 217 | ---------------- | ----------- | -------------------- 218 | | | | 219 | | V | 220 | | -------------- | -------------------- 221 | +--> | TAP parser |---+--> | Test summaries | 222 | -------------- -------------------- 223 | ]]> 224 |
225 | 226 | 227 | Additionally, utilities like "prove" can further simplify running a 228 | suite of TAP producers, by searching for files having certain 229 | characteristics or matching particular patterns. For instance, 230 | conventionally, all tests for a Perl module are stored in the 't/' 231 | folder, and consist of executable scripts (TAP producers) with 232 | extensions of 't'. The "prove" utility, part of the Test::Harness 233 | module, can then be used to find these files and run them all. In 234 | the following example, prove executes t/error.t, t/id.t and t/url.t 235 | and evaluates the produced TAP documents in turn, checking which 236 | ones passed and failed, and providing a complete summary of the 237 | entire test suite run. 238 | 239 | 240 |
247 |
248 | 249 |
250 | 251 | A TAP test set consists of one version, one plan, zero or more test 252 | results, and any number of comments and ignored elements. A TAP 253 | test set is split into lines, separated by newline characters. Any 254 | line beginning with the letters 'ok' or 'not ok' is a test result. 255 | All unparsable lines must be ignored by TAP consumers. In order to 256 | keep TAP readable on the system on which it is produced, the 257 | end-of-line character for TAP may be LF or CRLF. The same 258 | end-of-line character must be used throughout a document. 259 | 260 | 261 | 277 | 278 | 279 | Free-form strings in TAP, such as reasons and descriptions, must be 280 | in UTF8 unless the interchange parties agree otherwise. Strings 281 | MUST NOT contain an EOL or NUL character. Since directives start 282 | with a "#" and come after a description, descriptions MUST NOT 283 | contain a "#". 284 | 285 | 286 | 292 | 293 |
294 | 295 | Every test set as defined in this document should contain a 296 | version definition. A test set without a version definition 297 | is assumed to be written in TAP version 12, which is not 298 | covered by this document. 299 | 300 |
301 | 302 |
303 | 304 | Every test set should contain one and only one plan. A test 305 | set containing multiple plans can be parsed as a TAP 306 | document, but will be judged to have failed. 307 | 308 |
309 | 310 |
311 | 312 | A test result reports the status of one single test. The 313 | test must summarize itself as passing ("ok") or failing 314 | ("not ok"), and must have a test number. A test result 315 | without an explicit test number will be assumed to have the 316 | next number in increasing numeric sequence from the start 317 | of the test set. A test result can also have a description 318 | and a directive, which modifies the meaning of the test, 319 | but both are optional. 320 | 321 | 322 | 323 | Test results must be present in the correct order, without 324 | missing tests or duplicate test numbers, for the test set 325 | to be judged to pass. 326 | 327 |
328 | 329 |
330 | 331 | A Bail-Out line indicates a gross failure in the TAP 332 | producer. Results from this test set can no longer be 333 | trusted. The TAP consumer should ignore the rest of the TAP 334 | syntax and may terminate the TAP producer if it can do so 335 | safely. If processing multiple files, the TAP consumer 336 | should stop processing other files which are part of the 337 | same test suite. 338 | 339 |
340 | 341 |
342 | 343 | Comments are lines which have no meaning in TAP. They do 344 | not alter the result of a test. A TAP document with and 345 | without comments has exactly the same meaning. 346 | 347 | 348 | 349 | Comments typically contain debugging information. TAP 350 | consumers should not display comments by default, as there 351 | will likely be a large number of tests in such a suite. 352 | 353 | 354 | 355 | Note that TAP does not provide a mechanism for comments to 356 | be associated with particular test results; for instance, 357 | comments of a general nature might be interspersed with 358 | comments specific to a particular test. 359 | 360 |
361 | 362 |
363 | 364 | In order to allow extension of the protocol while 365 | maintaining backwards compatibility, a TAP consumer must 366 | ignore certain lines and elements. Any line which does not 367 | parse must be ignored. Any directive or plan-directive 368 | which is not recognized must also be ignored. 369 | 370 | 371 | 372 | Here's an example of a TAP stream which contains ignored elements. 373 | 374 | 375 |
381 | 382 | 383 | Line 2 should be ignored, it does not parse. The directive 384 | "BANG" on test #2 should be treated as an ordinary comment, 385 | it is not a TAP directive. 386 | 387 |
388 |
389 | 390 |
391 | 392 | The test set is defined below using Augmented Backus-Naur Form 393 | (ABNF), as defined in . 394 | 395 | 396 |
438 | 439 | 440 | A document must parse as per the grammar above to qualify as a TAP 441 | document. The grammar presented below may be used by TAP consumers 442 | to ensure that a test set contains all the required parts. 443 | 444 | 445 |
478 | 479 |
480 | 481 |
482 | 483 | Both test sets and test results can be determined to have 484 | passed or failed as detailed below. Note that a test set might 485 | fail even if every single test result contained in it passes. 486 | 487 | 488 |
489 | 490 | A test result indicates whether the test it reports has 491 | passed ("ok") or failed ("not ok"). It is itself said to 492 | pass or fail, depending on the result of the underlying 493 | test and on any directives applied to that result. It can 494 | be modified with any of the directives listed below. The 495 | table below summarises how directives can change a test 496 | result. 497 | 498 | 499 | 500 | 501 | No directives 502 | TODO 503 | SKIP 504 | ok 505 | pass 506 | pass (optionally with warning) 507 | pass 508 | not ok 509 | fail 510 | pass 511 | fail (with warning) 512 | 513 |
514 | 515 |
516 | 517 | This directive indicates that the test was not begun. Usually 518 | this is caused by environmental reasons: a missing optional 519 | library, an operating specific test, or an expensive test that 520 | is only run on request. 521 | 522 | 523 | 524 | Since the test was skipped, the test result is expected to be 525 | "ok" (indicating that the test was skipped correctly). A 526 | skipped test with a result of "not ok" is suspicious, and the 527 | TAP consumer should report a warning. 528 | 529 |
530 | 531 |
532 | 533 | This directive indicates that the test was run, but failure is 534 | expected and should not cause the test set to fail. This is 535 | usually because the functionality being tested has not been 536 | completely implemented or is obstructed by a known bug. 537 | 538 | 539 | 540 | Neither a failing nor a passing TODO test will cause the test 541 | set to fail, but since passing TODOs are suspicious, they may 542 | optionally be reported by TAP consumers. 543 | 544 | 545 | 556 |
557 | 558 |
559 | 560 | The plan indicates the number of tests which are expected to be 561 | run in the current test set. Two types of plans are defined, 562 | with different requirements for passing: 563 | 564 | 565 | 566 | 567 | 568 | A simple plan: the number of expected tests must be a 569 | positive integer. In order for a test set with a simple 570 | plan to pass, it must contain exactly the number of test 571 | results indicated in the plan, in ascending numeric order, 572 | without either any gaps in test number or any duplicate 573 | tests. Every test result must pass. 574 | 575 | 576 | 577 | A skip-all plan: the number of expected tests is zero. A 578 | test set with a skip-all plan passes unless it contains any 579 | test results. 580 | 581 | 582 | 583 | 584 | 585 | Allowing simple plans to plan for zero tests is being 586 | considered, but is not a part of this specification. 587 | 588 |
589 | 590 |
591 | 592 | TAP consumers may use any other system-specific factors to 593 | determine whether a test set passes or fails. If such a failure 594 | is to be reported, it MUST inform the user of the state of the 595 | TAP parsing and whether all tests appear to have passed, and 596 | then must separately describe the nature of the system-specific 597 | failure which caused the consumer to become suspicious of the 598 | results. 599 | 600 | 601 | 602 | TAP consumers which also act as TAP producers could add 603 | additional test results to the end of the output TAP document 604 | if such a failure occurs. For instance, take a TAP producer 605 | which emits ten successful tests, then throws an exception 606 | and exits with a failure. A filter might add a new (11th) 607 | failing ("not ok") test result to the end of the TAP it 608 | emits, which informs the user of the exception or failure 609 | exit code. Note that such a test result would cause the 610 | test set to fail; unless the test set planned one more test 611 | than it emitted, the number of tests would not equal the 612 | number of tests planned; even if it did this, this 11th 613 | failing test would cause the test set to fail. 614 | 615 | 616 | 617 | An example of the use of this option is to check exit codes of 618 | TAP producers for a failure, which might indicate that the 619 | producer failed after having emitted a complete TAP document. 620 | It seems unpragmatic to ignore such exit codes, but this 621 | information cannot be reliably expressed into its own TAP 622 | output by a failing producer, and must be treated separately. 623 | This also allows for language-specific and system-specific 624 | features to be used by the TAP consumer at its discretion to 625 | improve the rigour of its testing. 626 | 627 |
628 |
629 | 630 | 631 |
632 | 636 | 637 | A parser which stores test results in a dynamically sized array may 638 | be vulnerable to memory starvation by a test which uses a very high 639 | test number. For example: 640 | 641 | 642 |
648 | 649 | 650 | The above test result would cause an array of 123456789 elements to 651 | be allocated. So it is recommended that test results, if stored at 652 | all, are stored in a sparse array. 653 | 654 |
655 | 656 |
657 | 679 | TBD 680 |
681 | 682 |
683 | 684 | This document is based on Andy Armstrong's description of the TAP 685 | protocol, version 13, which is itself based on Andy Lester's 686 | description of the TAP protocol, version 1.00. The basis for the 687 | TAP format was created by Larry Wall in the original test script 688 | for Perl 1. Tim Bunce and Andreas Koenig developed it further 689 | with their modifications to the Test::Harness module. 690 | 691 |
692 |
693 | 694 | 695 | 696 | &rfc2119; 697 | &rfc5234; 698 | 699 | 700 | 701 |
702 | -------------------------------------------------------------------------------- /output/draft-vaidya-test-anything-protocol-00.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Network Working Group G. Vaidya, Ed. 5 | Internet-Draft M. Schwern 6 | Intended status: Informational October 29, 2009 7 | Expires: May 2, 2010 8 | 9 | 10 | The Test Anything Protocol (TAP) 11 | draft-vaidya-test-anything-protocol-00 12 | 13 | Status of this Memo 14 | 15 | By submitting this Internet-Draft, each author represents that any 16 | applicable patent or other IPR claims of which he or she is aware 17 | have been or will be disclosed, and any of which he or she becomes 18 | aware will be disclosed, in accordance with Section 6 of BCP 79. 19 | 20 | Internet-Drafts are working documents of the Internet Engineering 21 | Task Force (IETF), its areas, and its working groups. Note that 22 | other groups may also distribute working documents as Internet- 23 | Drafts. 24 | 25 | Internet-Drafts are draft documents valid for a maximum of six months 26 | and may be updated, replaced, or obsoleted by other documents at any 27 | time. It is inappropriate to use Internet-Drafts as reference 28 | material or to cite them other than as "work in progress." 29 | 30 | The list of current Internet-Drafts can be accessed at 31 | http://www.ietf.org/ietf/1id-abstracts.txt. 32 | 33 | The list of Internet-Draft Shadow Directories can be accessed at 34 | http://www.ietf.org/shadow.html. 35 | 36 | This Internet-Draft will expire on May 2, 2010. 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Vaidya & Schwern Expires May 2, 2010 [Page 1] 56 | 57 | Internet-Draft The Test Anything Protocol (TAP) October 2009 58 | 59 | 60 | Abstract 61 | 62 | The Test Anything Protocol (TAP) is a protocol to allow communication 63 | between unit tests and a test harness. It allows individual tests 64 | (TAP producers) to communicate test results to the testing harness in 65 | a language-agnostic way. Tests can indicate success, failure, as 66 | well as mark tests as unimplemented or skipped, and to provide 67 | additional information to aid in debugging of failed tests. Unlike 68 | other testing systems, it can indicate missing tests and duplicated 69 | tests. 70 | 71 | This specification defines TAP version 13. 72 | 73 | 74 | Table of Contents 75 | 76 | 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 77 | 1.1. Requirements notation . . . . . . . . . . . . . . . . . . 3 78 | 2. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 4 79 | 3. Producers and consumers . . . . . . . . . . . . . . . . . . . 6 80 | 4. The Structure of a TAP document . . . . . . . . . . . . . . . 8 81 | 4.1. Version . . . . . . . . . . . . . . . . . . . . . . . . . 8 82 | 4.2. Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 83 | 4.3. Test results . . . . . . . . . . . . . . . . . . . . . . . 8 84 | 4.4. Bail Out . . . . . . . . . . . . . . . . . . . . . . . . . 8 85 | 4.5. Comments . . . . . . . . . . . . . . . . . . . . . . . . . 9 86 | 4.6. Ignored elements . . . . . . . . . . . . . . . . . . . . . 9 87 | 5. Grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 88 | 6. Passing and Failing . . . . . . . . . . . . . . . . . . . . . 12 89 | 6.1. Test results . . . . . . . . . . . . . . . . . . . . . . . 12 90 | 6.2. The "SKIP" directive . . . . . . . . . . . . . . . . . . . 12 91 | 6.3. The "TODO" directive . . . . . . . . . . . . . . . . . . . 12 92 | 6.4. Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 93 | 6.5. Other factors . . . . . . . . . . . . . . . . . . . . . . 13 94 | 7. Security Considerations . . . . . . . . . . . . . . . . . . . 15 95 | 8. IANA considerations . . . . . . . . . . . . . . . . . . . . . 16 96 | 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 17 97 | 10. Normative References . . . . . . . . . . . . . . . . . . . . . 18 98 | Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 19 99 | Intellectual Property and Copyright Statements . . . . . . . . . . 20 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | Vaidya & Schwern Expires May 2, 2010 [Page 2] 112 | 113 | Internet-Draft The Test Anything Protocol (TAP) October 2009 114 | 115 | 116 | 1. Introduction 117 | 118 | The Test Anything Protocol (TAP) describes a standard format for 119 | testing suites to use. This format provides both human and machine- 120 | readable information on which tests were run, whether they were 121 | successful or failed, as well as other information which might be 122 | useful in tracing the cause of the failure. Being machine-readable 123 | allows this information to be easily parsed by an automated testing 124 | harness. Test results may then be summarized and analyzed. Being 125 | human-readable allows the results of a testing system to be read 126 | manually; this is useful for quickly determining whether individual 127 | tests pass and to aid in debugging the test system itself. 128 | 129 | TAP has been used by the Perl interpreter's test suite since 1987. 130 | 131 | 1.1. Requirements notation 132 | 133 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 134 | "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 135 | document are to be interpreted as described in [RFC2119]. 136 | 137 | The grammatical rules in this document are following ABNF and are to 138 | be interpreted as described in [RFC5234]. 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | Vaidya & Schwern Expires May 2, 2010 [Page 3] 168 | 169 | Internet-Draft The Test Anything Protocol (TAP) October 2009 170 | 171 | 172 | 2. Definitions 173 | 174 | Test: 175 | A piece of software which determines if a particular facility 176 | or component is functional. 177 | 178 | Test result: 179 | The encoding in TAP of the result of a single test. It may 180 | have exactly one TAP result directive. 181 | 182 | Test set: 183 | Zero or more test results with exactly one plan. A test set 184 | can be determined to have failed or passed. 185 | 186 | Test suite: 187 | A collection of test sets. 188 | 189 | TAP document: 190 | One test set which parses correctly as defined in this 191 | document. Future expansion may allow multiple test sets to be 192 | contained in a single TAP document, allowing an entire test 193 | suite to be stored as a single TAP document. 194 | 195 | Plan: 196 | The number of tests which are expected to pass in a single test 197 | set. 198 | 199 | Directive: 200 | A directive changes the meaning of a test result; it is 201 | commonly used to indicate that a failing test should be 202 | reported as passing (TODO) or that a passing test should be 203 | tagged as suspicious (SKIP). 204 | 205 | Reason: 206 | A reason explains why a directive was necessary. 207 | 208 | Description: 209 | A description says what a test result is testing. 210 | 211 | Producer: 212 | A producer is a thing which can generate a valid TAP document. 213 | 214 | Consumer: 215 | A consumer is a thing which can parse and interpret a TAP 216 | document. 217 | 218 | 219 | 220 | 221 | 222 | 223 | Vaidya & Schwern Expires May 2, 2010 [Page 4] 224 | 225 | Internet-Draft The Test Anything Protocol (TAP) October 2009 226 | 227 | 228 | Filter: 229 | A filter a piece of software which consumes a TAP document, and 230 | produces a new TAP document based in some way on the TAP input. 231 | For example, it can reproduce the TAP document exactly, 232 | normalize the formatting, combine multiple documents, or 233 | summarize the result of tests as a new TAP document. 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | Vaidya & Schwern Expires May 2, 2010 [Page 5] 280 | 281 | Internet-Draft The Test Anything Protocol (TAP) October 2009 282 | 283 | 284 | 3. Producers and consumers 285 | 286 | A TAP document might exist as a file, data stream, encoded in another 287 | medium (stored in a PDF file, for instance) or in any other form 288 | which can be parsed as described below. For maximum compatibility, 289 | it may be produced by any TAP producer, and must then be consumable 290 | by any TAP consumer. 291 | 292 | One example system of producers and consumers is the Test::More/ 293 | Test::Harness system in Perl testing. In this system, test producers 294 | are executable Perl scripts with a '.t' extension, collected in a 295 | number of folders, which themselves use the Test::More library to 296 | simplify testing. These scripts can be executed individually, and 297 | emit TAP documents on standard output. 298 | 299 | A TAP consumer, such as the Perl module TAP::Parser, can interpret 300 | the output of a TAP producer to determine how many tests were run, 301 | which tests succeeded, and which diagnostic information might be 302 | usefully reported to the user. 303 | 304 | Note that these two processes are often decoupled. The TAP document 305 | emitted by the TAP producer can be stored before being interpreted by 306 | the TAP parser; this allows all diagnostic and testing information to 307 | be stored for later analysis and usage. The TAP document might be 308 | generated on one server, then downloaded to another before being 309 | processed. A single TAP parser can be used to process files in all 310 | these cases, illustrating TAP's utility as a cross-language, cross- 311 | environment tool. 312 | 313 | The complete flow in this system can look something like this: 314 | 315 | ------------ 316 | | Producer | 317 | ------------ 318 | | 319 | V 320 | ---------------- ----------- -------------------- 321 | | TAP document | --+--> | Storage | +--> | Formatted Output | 322 | ---------------- | ----------- | -------------------- 323 | | | | 324 | | V | 325 | | -------------- | -------------------- 326 | +--> | TAP parser |---+--> | Test summaries | 327 | -------------- -------------------- 328 | 329 | Additionally, utilities like "prove" can further simplify running a 330 | suite of TAP producers, by searching for files having certain 331 | characteristics or matching particular patterns. For instance, 332 | 333 | 334 | 335 | Vaidya & Schwern Expires May 2, 2010 [Page 6] 336 | 337 | Internet-Draft The Test Anything Protocol (TAP) October 2009 338 | 339 | 340 | conventionally, all tests for a Perl module are stored in the 't/' 341 | folder, and consist of executable scripts (TAP producers) with 342 | extensions of 't'. The "prove" utility, part of the Test::Harness 343 | module, can then be used to find these files and run them all. In 344 | the following example, prove executes t/error.t, t/id.t and t/url.t 345 | and evaluates the produced TAP documents in turn, checking which ones 346 | passed and failed, and providing a complete summary of the entire 347 | test suite run. 348 | 349 | $ prove t/*.t 350 | t/error.t...ok 351 | t/id.t......ok 352 | t/url.t.....ok 353 | Result: PASS 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | Vaidya & Schwern Expires May 2, 2010 [Page 7] 392 | 393 | Internet-Draft The Test Anything Protocol (TAP) October 2009 394 | 395 | 396 | 4. The Structure of a TAP document 397 | 398 | A TAP test set consists of one version, one plan, zero or more test 399 | results, and any number of comments and ignored elements. A TAP test 400 | set is split into lines, separated by newline characters. Any line 401 | beginning with the letters 'ok' or 'not ok' is a test result. All 402 | unparsable lines must be ignored by TAP consumers. In order to keep 403 | TAP readable on the system on which it is produced, the end-of-line 404 | character for TAP may be LF or CRLF. The same end-of-line character 405 | must be used throughout a document. 406 | 407 | Free-form strings in TAP, such as reasons and descriptions, must be 408 | in UTF8 unless the interchange parties agree otherwise. Strings MUST 409 | NOT contain an EOL or NUL character. Since directives start with a 410 | "#" and come after a description, descriptions MUST NOT contain a 411 | "#". 412 | 413 | 4.1. Version 414 | 415 | Every test set as defined in this document should contain a version 416 | definition. A test set without a version definition is assumed to be 417 | written in TAP version 12, which is not covered by this document. 418 | 419 | 4.2. Plan 420 | 421 | Every test set should contain one and only one plan. A test set 422 | containing multiple plans can be parsed as a TAP document, but will 423 | be judged to have failed. 424 | 425 | 4.3. Test results 426 | 427 | A test result reports the status of one single test. The test must 428 | summarize itself as passing ("ok") or failing ("not ok"), and must 429 | have a test number. A test result without an explicit test number 430 | will be assumed to have the next number in increasing numeric 431 | sequence from the start of the test set. A test result can also have 432 | a description and a directive, which modifies the meaning of the 433 | test, but both are optional. 434 | 435 | Test results must be present in the correct order, without missing 436 | tests or duplicate test numbers, for the test set to be judged to 437 | pass. 438 | 439 | 4.4. Bail Out 440 | 441 | A Bail-Out line indicates a gross failure in the TAP producer. 442 | Results from this test set can no longer be trusted. The TAP 443 | consumer should ignore the rest of the TAP syntax and may terminate 444 | 445 | 446 | 447 | Vaidya & Schwern Expires May 2, 2010 [Page 8] 448 | 449 | Internet-Draft The Test Anything Protocol (TAP) October 2009 450 | 451 | 452 | the TAP producer if it can do so safely. If processing multiple 453 | files, the TAP consumer should stop processing other files which are 454 | part of the same test suite. 455 | 456 | 4.5. Comments 457 | 458 | Comments are lines which have no meaning in TAP. They do not alter 459 | the result of a test. A TAP document with and without comments has 460 | exactly the same meaning. 461 | 462 | Comments typically contain debugging information. TAP consumers 463 | should not display comments by default, as there will likely be a 464 | large number of tests in such a suite. 465 | 466 | Note that TAP does not provide a mechanism for comments to be 467 | associated with particular test results; for instance, comments of a 468 | general nature might be interspersed with comments specific to a 469 | particular test. 470 | 471 | 4.6. Ignored elements 472 | 473 | In order to allow extension of the protocol while maintaining 474 | backwards compatibility, a TAP consumer must ignore certain lines and 475 | elements. Any line which does not parse must be ignored. Any 476 | directive or plan-directive which is not recognized must also be 477 | ignored. 478 | 479 | Here's an example of a TAP stream which contains ignored elements. 480 | 481 | 1..2 # Line 1 482 | Error at line 12 # Line 2 483 | ok 1 # Line 3 484 | ok 2 # BANG # Line 4 485 | 486 | Line 2 should be ignored, it does not parse. The directive "BANG" on 487 | test #2 should be treated as an ordinary comment, it is not a TAP 488 | directive. 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | Vaidya & Schwern Expires May 2, 2010 [Page 9] 504 | 505 | Internet-Draft The Test Anything Protocol (TAP) October 2009 506 | 507 | 508 | 5. Grammar 509 | 510 | The test set is defined below using Augmented Backus-Naur Form 511 | (ABNF), as defined in [RFC5234]. 512 | 513 | ; Overall structure 514 | Testset = Header (Plan Body / Body Plan) Footer 515 | Header = [Comments] [Version] 516 | Footer = [Comments] 517 | Body = *(Comment / TAP-Line) 518 | TAP-Line = Test-Result / Bail-Out 519 | 520 | ; TAP version 521 | Version = "TAP version" SP Version-Number EOL 522 | Version-Number = Positive-Integer 523 | 524 | ; Plan 525 | Plan = ( Plan-Simple / Plan-Todo / Plan-Skip-All ) EOL 526 | Plan-Simple = "1.." Number-Of-Tests 527 | Plan-Todo = Plan-Simple "todo" 1*(SP Test-Number) ";" 528 | Plan-Skip-All = "1..0" SP "skip" SP Reason 529 | Reason = String 530 | Number-Of-Tests = 1*DIGIT 531 | Test-Number = Positive-Integer 532 | 533 | ; Test result 534 | Test-Result = Status [SP Test-Number] [SP Description] 535 | [SP "#" SP Directive [SP Reason]] EOL 536 | Status = "ok" / "not ok" 537 | Description = Safe-String 538 | Directive = "SKIP" / "TODO" 539 | 540 | ; Bail out 541 | Bail-Out = "Bail out!" [SP Reason] EOL 542 | 543 | ; Comments 544 | Comment = "#" String EOL 545 | Comments = 1*Comment 546 | 547 | ; Values 548 | EOL = LF / CRLF 549 | Safe-String = 1*(%x01-09 %x0B-0C %x0E-22 %x24-FF) 550 | String = 1*(Safe-String / "#") 551 | Positive-Integer = 552 | ("1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9") *DIGIT 553 | 554 | A document must parse as per the grammar above to qualify as a TAP 555 | document. The grammar presented below may be used by TAP consumers 556 | 557 | 558 | 559 | Vaidya & Schwern Expires May 2, 2010 [Page 10] 560 | 561 | Internet-Draft The Test Anything Protocol (TAP) October 2009 562 | 563 | 564 | to ensure that a test set contains all the required parts. 565 | 566 | ; Overall structure 567 | Passing-Testset = Header 568 | ( 569 | Plan-With-Tests Passing-Body 570 | / 571 | Passing-Body Plan-With-Tests 572 | / 573 | Plan-Skip-All 574 | ) 575 | Footer 576 | Passing-Body = 577 | [Comments] 1*Passing-Line *(Passing-Line / Comment) [Comments] 578 | Passing-Line = 579 | (Simple-OK / Passing-TODO / Failing-TODO / Passing-SKIP) EOL 580 | Failing-Line = 581 | (Simple-Fail / Failing-SKIP) EOL 582 | 583 | ; Plans that must have tests 584 | Plan-With-Tests = ( Plan-Simple / Plan-Todo ) 585 | 586 | ; Passing and failing test lines 587 | Simple-OK = 588 | "ok" [SP Test-Number] [SP Description] 589 | Simple-Fail = 590 | "not ok" [SP Test-Number] [SP Description] 591 | Passing-TODO = Simple-OK SP TODO-Directive 592 | Failing-TODO = Simple-Fail SP TODO-Directive 593 | Passing-SKIP = Simple-OK SP SKIP-Directive 594 | Failing-SKIP = Simple-Fail SP SKIP-Directive 595 | TODO-Directive = "# TODO" [SP Reason] 596 | SKIP-Directive = "# SKIP" [SP Reason] 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | Vaidya & Schwern Expires May 2, 2010 [Page 11] 616 | 617 | Internet-Draft The Test Anything Protocol (TAP) October 2009 618 | 619 | 620 | 6. Passing and Failing 621 | 622 | Both test sets and test results can be determined to have passed or 623 | failed as detailed below. Note that a test set might fail even if 624 | every single test result contained in it passes. 625 | 626 | 6.1. Test results 627 | 628 | A test result indicates whether the test it reports has passed ("ok") 629 | or failed ("not ok"). It is itself said to pass or fail, depending 630 | on the result of the underlying test and on any directives applied to 631 | that result. It can be modified with any of the directives listed 632 | below. The table below summarises how directives can change a test 633 | result. 634 | 635 | +--------+------------+---------------------------+-----------------+ 636 | | | No | TODO | SKIP | 637 | | | directives | | | 638 | +--------+------------+---------------------------+-----------------+ 639 | | ok | pass | pass | pass | 640 | | | | (optionally with warning) | | 641 | | | | | | 642 | | not ok | fail | pass | fail | 643 | | | | | (with warning) | 644 | +--------+------------+---------------------------+-----------------+ 645 | 646 | Test results as modified by directives 647 | 648 | 6.2. The "SKIP" directive 649 | 650 | This directive indicates that the test was not begun. Usually this 651 | is caused by environmental reasons: a missing optional library, an 652 | operating specific test, or an expensive test that is only run on 653 | request. 654 | 655 | Since the test was skipped, the test result is expected to be "ok" 656 | (indicating that the test was skipped correctly). A skipped test 657 | with a result of "not ok" is suspicious, and the TAP consumer should 658 | report a warning. 659 | 660 | 6.3. The "TODO" directive 661 | 662 | This directive indicates that the test was run, but failure is 663 | expected and should not cause the test set to fail. This is usually 664 | because the functionality being tested has not been completely 665 | implemented or is obstructed by a known bug. 666 | 667 | Neither a failing nor a passing TODO test will cause the test set to 668 | 669 | 670 | 671 | Vaidya & Schwern Expires May 2, 2010 [Page 12] 672 | 673 | Internet-Draft The Test Anything Protocol (TAP) October 2009 674 | 675 | 676 | fail, but since passing TODOs are suspicious, they may optionally be 677 | reported by TAP consumers. 678 | 679 | 6.4. Plan 680 | 681 | The plan indicates the number of tests which are expected to be run 682 | in the current test set. Two types of plans are defined, with 683 | different requirements for passing: 684 | 685 | 1. A simple plan: the number of expected tests must be a positive 686 | integer. In order for a test set with a simple plan to pass, it 687 | must contain exactly the number of test results indicated in the 688 | plan, in ascending numeric order, without either any gaps in test 689 | number or any duplicate tests. Every test result must pass. 690 | 691 | 2. A skip-all plan: the number of expected tests is zero. A test 692 | set with a skip-all plan passes unless it contains any test 693 | results. 694 | 695 | Allowing simple plans to plan for zero tests is being considered, but 696 | is not a part of this specification. 697 | 698 | 6.5. Other factors 699 | 700 | TAP consumers may use any other system-specific factors to determine 701 | whether a test set passes or fails. If such a failure is to be 702 | reported, it MUST inform the user of the state of the TAP parsing and 703 | whether all tests appear to have passed, and then must separately 704 | describe the nature of the system-specific failure which caused the 705 | consumer to become suspicious of the results. 706 | 707 | TAP consumers which also act as TAP producers could add additional 708 | test results to the end of the output TAP document if such a failure 709 | occurs. For instance, take a TAP producer which emits ten successful 710 | tests, then throws an exception and exits with a failure. A filter 711 | might add a new (11th) failing ("not ok") test result to the end of 712 | the TAP it emits, which informs the user of the exception or failure 713 | exit code. Note that such a test result would cause the test set to 714 | fail; unless the test set planned one more test than it emitted, the 715 | number of tests would not equal the number of tests planned; even if 716 | it did this, this 11th failing test would cause the test set to fail. 717 | 718 | An example of the use of this option is to check exit codes of TAP 719 | producers for a failure, which might indicate that the producer 720 | failed after having emitted a complete TAP document. It seems 721 | unpragmatic to ignore such exit codes, but this information cannot be 722 | reliably expressed into its own TAP output by a failing producer, and 723 | must be treated separately. This also allows for language-specific 724 | 725 | 726 | 727 | Vaidya & Schwern Expires May 2, 2010 [Page 13] 728 | 729 | Internet-Draft The Test Anything Protocol (TAP) October 2009 730 | 731 | 732 | and system-specific features to be used by the TAP consumer at its 733 | discretion to improve the rigour of its testing. 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | Vaidya & Schwern Expires May 2, 2010 [Page 14] 784 | 785 | Internet-Draft The Test Anything Protocol (TAP) October 2009 786 | 787 | 788 | 7. Security Considerations 789 | 790 | A parser which stores test results in a dynamically sized array may 791 | be vulnerable to memory starvation by a test which uses a very high 792 | test number. For example: 793 | 794 | 1..3 795 | ok 1 796 | ok 2 797 | ok 123456789 798 | 799 | The above test result would cause an array of 123456789 elements to 800 | be allocated. So it is recommended that test results, if stored at 801 | all, are stored in a sparse array. 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | Vaidya & Schwern Expires May 2, 2010 [Page 15] 840 | 841 | Internet-Draft The Test Anything Protocol (TAP) October 2009 842 | 843 | 844 | 8. IANA considerations 845 | 846 | TBD 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | Vaidya & Schwern Expires May 2, 2010 [Page 16] 896 | 897 | Internet-Draft The Test Anything Protocol (TAP) October 2009 898 | 899 | 900 | 9. Acknowledgements 901 | 902 | This document is based on Andy Armstrong's description of the TAP 903 | protocol, version 13, which is itself based on Andy Lester's 904 | description of the TAP protocol, version 1.00. The basis for the TAP 905 | format was created by Larry Wall in the original test script for 906 | Perl 1. Tim Bunce and Andreas Koenig developed it further with their 907 | modifications to the Test::Harness module. 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | Vaidya & Schwern Expires May 2, 2010 [Page 17] 952 | 953 | Internet-Draft The Test Anything Protocol (TAP) October 2009 954 | 955 | 956 | 10. Normative References 957 | 958 | [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 959 | Requirement Levels", BCP 14, RFC 2119, March 1997. 960 | 961 | [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 962 | Specifications: ABNF", STD 68, RFC 5234, January 2008. 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | Vaidya & Schwern Expires May 2, 2010 [Page 18] 1008 | 1009 | Internet-Draft The Test Anything Protocol (TAP) October 2009 1010 | 1011 | 1012 | Authors' Addresses 1013 | 1014 | Gaurav Vaidya (editor) 1015 | 1016 | 1017 | Michael G Schwern 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | Vaidya & Schwern Expires May 2, 2010 [Page 19] 1064 | 1065 | Internet-Draft The Test Anything Protocol (TAP) October 2009 1066 | 1067 | 1068 | Full Copyright Statement 1069 | 1070 | Copyright (C) The IETF Trust (2009). 1071 | 1072 | This document is subject to the rights, licenses and restrictions 1073 | contained in BCP 78, and except as set forth therein, the authors 1074 | retain all their rights. 1075 | 1076 | This document and the information contained herein are provided on an 1077 | "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS 1078 | OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND 1079 | THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS 1080 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF 1081 | THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED 1082 | WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 1083 | 1084 | 1085 | Intellectual Property 1086 | 1087 | The IETF takes no position regarding the validity or scope of any 1088 | Intellectual Property Rights or other rights that might be claimed to 1089 | pertain to the implementation or use of the technology described in 1090 | this document or the extent to which any license under such rights 1091 | might or might not be available; nor does it represent that it has 1092 | made any independent effort to identify any such rights. Information 1093 | on the procedures with respect to rights in RFC documents can be 1094 | found in BCP 78 and BCP 79. 1095 | 1096 | Copies of IPR disclosures made to the IETF Secretariat and any 1097 | assurances of licenses to be made available, or the result of an 1098 | attempt made to obtain a general license or permission for the use of 1099 | such proprietary rights by implementers or users of this 1100 | specification can be obtained from the IETF on-line IPR repository at 1101 | http://www.ietf.org/ipr. 1102 | 1103 | The IETF invites any interested party to bring to its attention any 1104 | copyrights, patents or patent applications, or other proprietary 1105 | rights that may cover technology that may be required to implement 1106 | this standard. Please address the information to the IETF at 1107 | ietf-ipr@ietf.org. 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | Vaidya & Schwern Expires May 2, 2010 [Page 20] 1120 | 1121 | --------------------------------------------------------------------------------