Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Test examples that recreate lang analyzers #29535

Merged
merged 28 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e37aae1
Wip
nik9000 Apr 13, 2018
062f66b
Merge branch 'master' into builtin_analyzer_tests
nik9000 Apr 13, 2018
b9bbf66
Docs: Test examples that recreate lang analyzers
nik9000 Apr 13, 2018
0a1d66d
Fix names
nik9000 Apr 16, 2018
5274dcd
Merge branch 'master' into builtin_analyzer_tests
nik9000 Apr 17, 2018
ec2eef7
Spaces
nik9000 Apr 19, 2018
27c9dc1
Document sytax enhancement
nik9000 Apr 19, 2018
d3a87f4
Merge branch 'master' into builtin_analyzer_tests
nik9000 Apr 20, 2018
bf17504
Fixes
nik9000 Apr 20, 2018
90bce00
Merge branch 'master' into builtin_analyzer_tests
nik9000 Apr 25, 2018
91cac14
Merge branch 'master' into builtin_analyzer_tests
nik9000 Apr 27, 2018
3579f83
Move flag
nik9000 Apr 27, 2018
881a25d
Merge branch 'master' into builtin_analyzer_tests
nik9000 Apr 27, 2018
d309405
Fix up irish stemmer
nik9000 Apr 27, 2018
bd10c4a
,
nik9000 Apr 27, 2018
43b2213
Fix irish better
nik9000 Apr 27, 2018
0e6b62f
Fix cjk
nik9000 Apr 27, 2018
2c77a97
.
nik9000 Apr 27, 2018
5ba12d1
,
nik9000 Apr 27, 2018
f4c2220
, againt
nik9000 Apr 27, 2018
b58330b
Sigh
nik9000 Apr 27, 2018
e93cb96
Merge branch 'master' into builtin_analyzer_tests
nik9000 Apr 27, 2018
dcf25b5
Fix precommit
nik9000 Apr 28, 2018
5069ac0
Merge branch 'master' into builtin_analyzer_tests
nik9000 May 1, 2018
3c0f070
Remove errant class file
nik9000 May 7, 2018
21b0647
Merge branch 'master' into builtin_analyzer_tests
nik9000 May 7, 2018
8c2150d
Add warning
nik9000 May 7, 2018
2f8af5c
Merge branch 'master' into builtin_analyzer_tests
nik9000 May 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
private static final String SYNTAX = {
String method = /(?<method>GET|PUT|POST|HEAD|OPTIONS|DELETE)/
String pathAndQuery = /(?<pathAndQuery>[^\n]+)/
String badBody = /GET|PUT|POST|HEAD|OPTIONS|DELETE|#/
String badBody = /GET|PUT|POST|HEAD|OPTIONS|DELETE|startyaml|#/
String body = /(?<body>(?:\n(?!$badBody)[^\n]+)+)/
String nonComment = /$method\s+$pathAndQuery$body?/
String rawRequest = /(?:$method\s+$pathAndQuery$body?)/
String yamlRequest = /(?:startyaml(?s)(?<yaml>.+?)(?-s)endyaml)/
String nonComment = /(?:$rawRequest|$yamlRequest)/
String comment = /(?<comment>#.+)/
/(?:$comment|$nonComment)\n+/
}()
Expand Down Expand Up @@ -333,6 +335,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
// Comment
return
}
String yamlRequest = matcher.group("yaml");
if (yamlRequest != null) {
current.println(yamlRequest)
return
}
String method = matcher.group("method")
String pathAndQuery = matcher.group("pathAndQuery")
String body = matcher.group("body")
Expand Down
17 changes: 17 additions & 0 deletions docs/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ for its modifiers:
but rather than the setup defined in `docs/build.gradle` the setup is defined
right in the documentation file.

In addition to the standard CONSOLE syntax these snippets can contain blocks
of yaml surrounded by markers like this:

```
startyaml
- compare_analyzers: {index: thai_example, first: thai, second: rebuilt_thai}
endyaml
```

This allows slightly more expressive testing of the snippets. Since that syntax
is not supported by CONSOLE the usual way to incorporate it is with a
`// TEST[s//]` marker like this:

```
// TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: thai_example, first: thai, second: rebuilt_thai}\nendyaml\n/]
```

Any place you can use json you can use elements like `$body.path.to.thing`
which is replaced on the fly with the contents of the thing at `path.to.thing`
in the last response.
2 changes: 2 additions & 0 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ buildRestTests.docs = fileTree(projectDir) {
exclude 'build.gradle'
// That is where the snippets go, not where they come from!
exclude 'build'
// Just syntax examples
exclude 'README.asciidoc'
}

Closure setupTwitter = { String name, int count ->
Expand Down
Loading