镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

whitespace before directive? #28

Closed

Description

@isaacs

Can I get a ruling on this?

TAP version 13
# this should be a skip test, obviously
ok 1 - description # skip

# no whitespace after #, is this skipped?
ok 2 - description #skip

# no whitespace before #, is this skipped?
ok 3 - description# skip

# no whitespace anywhere, is this skipped?
ok 4 - description#skip

# no description, whitespace after
ok 5 # skip

# no description, no whitespace after
ok 6 #skip

1..6

If we already effectively require (or wish to require) whitespace surrounding the # character, then we can specify the directive parsing much more simply, because there's no way it could ever be escaped with \.

ping @mblayman @exodist @Leont @kinow

Activity

  1. isaacs commented on Mar 11, 2022

    @isaacs
    ContributorAuthor

    Here's what I see when I paste that into node-tap's parser and tell it to spit out TAP for what it interpreted:

    $ pbpaste | node ./bin/cmd.js -t
    TAP version 13
    # this should be a skip test, obviously
    ok 1 - description # SKIP
    # no whitespace after #, is this skipped?
    ok 2 - description # SKIP
    # no whitespace before #, is this skipped?
    ok 3 - description\# skip
    # no whitespace anywhere, is this skipped?
    ok 4 - description\#skip
    # no description, whitespace after
    ok 5 # SKIP
    # no description, no whitespace after
    ok 6 # SKIP
    1..6
    # skip: 4
    

    Node-tap requires whitespace before the #, but not after.

  2. kinow commented on Mar 12, 2022

    @kinow
    Member

    IMO:

    TAP version 13
    # this should be a skip test, obviously 🙆🏻
    ok 1 - description # skip
    
    # no whitespace after #, is this skipped? 🙅🏻
    ok 2 - description #skip
    
    # no whitespace before #, is this skipped?🙅🏻
    ok 3 - description# skip
    
    # no whitespace anywhere, is this skipped?🙅🏻
    ok 4 - description#skip
    
    # no description, whitespace after🙆🏻
    ok 5 # skip
    
    # no description, no whitespace after🙅🏻
    ok 6 #skip
    
    1..6
    

    Just because it's simpler to tokenize/parse with a space before and after, and I think making the description optional would be fine too.

  3. Leont commented on Mar 12, 2022

    @Leont

    Main producers in Perl and Raku output spaces before and after.
    Two consumers accept # with or without spaces before or after it, one of them (Test2::Harness) gives a warning if the space before the directive is missing (but will otherwise parse it)

  4. mblayman commented on Mar 12, 2022

    @mblayman
    Member

    tappy considers all 6 as skips and doesn't really care about the whitespace before or after.

    (venv) ➜  tappy git:(main) tap skip_whitespace.tap 
    ssssss
    ----------------------------------------------------------------------
    Ran 6 tests in 0.000s
    
    OK (skipped=6)

    I don't have strong feelings about this topic. If we think it would be easier to make a valid consumer by expecting more whitespace, that seems fine to me.

  5. isaacs commented on Mar 12, 2022

    @isaacs
    ContributorAuthor

    Thanks everyone. In the interest of "specify what we have", how does this sound:

    1. Producers must output \s+#\s+${directive} for directives
    2. Harnesses must not treat \\#\s*\S+ as a directive (escaped)
    3. Harnesses must treat \s#\s+\S+ as a directive
    4. Harnesses may treat \S#\s+\S+, \s#\S+, or \S#\S+ as a directive, but should warn that this is invalid.

    I think if that's how we specify it, then everyone is compliant, and there's still some decent guidance for new consumers (they don't have to support anything other than ok 1 - name # skip, but they can if they want to).

  6. isaacs commented on Mar 12, 2022

    @isaacs
    ContributorAuthor

    I'll try to make the language more precise than this and provide examples, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions