Skip to content
This repository was archived by the owner on Mar 24, 2021. It is now read-only.

Write a blog post about testing in go-rst #26

Open
demizer opened this issue Dec 6, 2014 · 0 comments
Open

Write a blog post about testing in go-rst #26

demizer opened this issue Dec 6, 2014 · 0 comments
Labels

Comments

@demizer
Copy link
Owner

demizer commented Dec 6, 2014

Requies #10

The blog post should cover:

  1. Converting docutils tests to json
    1. Problems with docutils tests
      • psuedo xml not easily portable
    2. testdata
      1. portable rst tests are easier to use.
        • Lex items are easy to setup with separate rst file.
        • UltiSnips for fast *-items.json and *-node.json file creation.
      2. comparing json objects is painful, but not too bad. Highlight recursive compare code.
  2. Test infrastructure
    1. testdata directory structure
      • Good and Bad tests
    2. Debug output
    3. go debugger? delve?
    4. calling test data
      • test.go files and adding a new test.

      • running a single test

      • debugging a test problem
        Remove lines 442-451 in parse_test.go to produce a panic.
        Readd the lines and show the following error:

        [demizer@lithium]$ gtr TestParseCommentNoBlankLineBad0000
        === RUN TestParseCommentNoBlankLineBad0000
        
        
        Sat Dec 06 13:31:06 PST 2014 :: [CRITICAL] 3 Parse Nodes
        
        ([]parse.Node) (len=3 cap=4) {
          (*parse.CommentNode)(0xc2080b5980)({
              ID: (parse.ID) 1,
              Type: (parse.NodeType) 8,
              Text: (string) (len=9) "A comment",
              Length: (int) 9,
              StartPosition: (parse.StartPosition) 4,
              Line: (parse.Line) 1
          }),
          (*parse.ParagraphNode)(0xc2080b5bc0)({
              ID: (parse.ID) 2,
              Type: (parse.NodeType) 1,
              Text: (string) (len=13) "no blank line",
              Length: (int) 13,
              Line: (parse.Line) 2,
              StartPosition: (parse.StartPosition) 1
          }),
          (*parse.ParagraphNode)(0xc2080b5e00)({
              ID: (parse.ID) 3,
              Type: (parse.NodeType) 1,
              Text: (string) (len=12) "A paragraph.",
              Length: (int) 12,
              Line: (parse.Line) 4,
              StartPosition: (parse.StartPosition) 1
          })
        }
        
        
        Sat Dec 06 13:31:06 PST 2014 :: [CRITICAL] 4 Expected Nodes
        
        ([]interface {}) (len=4 cap=4) {
          (map[string]interface {}) (len=6) {
              (string) (len=13) "startPosition": (float64) 4,
              (string) (len=4) "line": (float64) 1,
              (string) (len=6) "length": (float64) 9,
              (string) (len=2) "id": (float64) 1,
              (string) (len=4) "type": (string) (len=11) "NodeComment",
              (string) (len=4) "text": (string) (len=9) "A comment"
          },
          (map[string]interface {}) (len=5) {
              (string) (len=4) "type": (string) (len=17) "NodeSystemMessage",
              (string) (len=8) "severity": (string) (len=7) "WARNING",
              (string) (len=4) "line": (float64) 2,
              (string) (len=8) "nodeList": ([]interface {}) (len=1 cap=1) {
                  (map[string]interface {}) (len=4) {
                      (string) (len=2) "id": (float64) 3,
                      (string) (len=4) "type": (string) (len=13) "NodeParagraph",
                      (string) (len=4) "text": (string) (len=63) "Explicit markup ends without a blank line; unexpected unindent.",
                      (string) (len=6) "length": (float64) 63
                  }
              },
              (string) (len=2) "id": (float64) 2
          },
          (map[string]interface {}) (len=6) {
              (string) (len=6) "length": (float64) 13,
              (string) (len=2) "id": (float64) 4,
              (string) (len=4) "type": (string) (len=13) "NodeParagraph",
              (string) (len=4) "text": (string) (len=13) "no blank line",
              (string) (len=13) "startPosition": (float64) 1,
              (string) (len=4) "line": (float64) 2
          },
          (map[string]interface {}) (len=6) {
              (string) (len=4) "text": (string) (len=11) "A paragraph",
              (string) (len=13) "startPosition": (float64) 1,
              (string) (len=4) "line": (float64) 4,
              (string) (len=6) "length": (float64) 11,
              (string) (len=2) "id": (float64) 5,
              (string) (len=4) "type": (string) (len=13) "NodeParagraph"
          }
        }
        
        
        Sat Dec 06 13:31:06 PST 2014 :: [CRITICAL] The number of parsed nodes does not match expected nodes!
        exit status 1
        FAIL  github.com/demizer/go-rst/parse 0.005s
        
@demizer demizer added the Website label Dec 6, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant