Add testdata from reported issues

This commit is contained in:
Christian Muehlhaeuser
2019-12-28 05:50:15 +01:00
parent 1d45bba66d
commit 33bf4bcc82
13 changed files with 165 additions and 3 deletions
+75 -3
View File
@@ -16,8 +16,10 @@ import (
)
const (
generate = false
examplesDir = "../styles/examples/"
generateExamples = false
generateIssues = false
examplesDir = "../styles/examples/"
issuesDir = "../testdata/issues/"
)
func TestRenderer(t *testing.T) {
@@ -70,7 +72,77 @@ func TestRenderer(t *testing.T) {
}
// generate
if generate {
if generateExamples {
err = ioutil.WriteFile(tn, buf.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
continue
}
// verify
td, err := ioutil.ReadFile(tn)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(td, buf.Bytes()) {
t.Errorf("Rendered output for %s doesn't match!\nExpected: `\n%s`\nGot: `\n%s`\n",
bn, string(td), buf.String())
}
}
}
func TestRendererIssues(t *testing.T) {
files, err := filepath.Glob(issuesDir + "*.md")
if err != nil {
t.Fatal(err)
}
for _, f := range files {
bn := strings.TrimSuffix(filepath.Base(f), ".md")
tn := filepath.Join(issuesDir, bn+".test")
in, err := ioutil.ReadFile(f)
if err != nil {
t.Fatal(err)
}
b, err := ioutil.ReadFile("../styles/dark.json")
if err != nil {
t.Fatal(err)
}
options := Options{
WordWrap: 80,
}
err = json.Unmarshal(b, &options.Styles)
if err != nil {
t.Fatal(err)
}
md := goldmark.New(
goldmark.WithExtensions(
extension.GFM,
extension.DefinitionList,
),
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
)
ar := NewRenderer(options)
md.SetRenderer(
renderer.NewRenderer(
renderer.WithNodeRenderers(util.Prioritized(ar, 1000))))
var buf bytes.Buffer
err = md.Convert(in, &buf)
if err != nil {
t.Error(err)
}
// generate
if generateIssues {
err = ioutil.WriteFile(tn, buf.Bytes(), 0644)
if err != nil {
t.Fatal(err)
+5
View File
@@ -0,0 +1,5 @@
If you want to make a more significant change, please first [open an
issue](https://github.com/twpayne/chezmoi/issues/new) to discuss the change that
you want to make. Dave Cheney gives a [good
rationale](https://dave.cheney.net/2019/02/18/talk-then-code) as to why this is
important.
+6
View File
@@ -0,0 +1,6 @@
 If you want to make a more significant change, please first open an issue     
 https://github.com/twpayne/chezmoi/issues/new to discuss the change that you  
 want to make. Dave Cheney gives a good rationale                              
 https://dave.cheney.net/2019/02/18/talk-then-code as to why this is important.
+7
View File
@@ -0,0 +1,7 @@
* [Getting started](#getting-started)
* [Developing locally](#developing-locally)
* [Documentation changes](#documentation-changes)
* [Contributing changes](#contributing-changes)
* [Managing releases](#managing-releases)
* [Packaging](#packaging)
* [Updating the website](#updating-the-website)
+10
View File
@@ -0,0 +1,10 @@
                                                                              
 • Getting started                                                             
 • Developing locally                                                          
 • Documentation changes                                                       
 • Contributing changes                                                        
 • Managing releases                                                           
 • Packaging                                                                   
 • Updating the website                                                        
+6
View File
@@ -0,0 +1,6 @@
| Distribution | Architectures | Package |
| ------------ | --------------------------------------------------------- | ------------------------------------------------------------------------- |
| Debian | `amd64`, `arm64`, `armel`, `i386`, `ppc64`, `ppc64le` | [`deb`](https://github.com/twpayne/chezmoi/releases/latest) |
| RedHat | `aarch64`, `armhfp`, `i686`, `ppc64`, `ppc64le`, `x86_64` | [`rpm`](https://github.com/twpayne/chezmoi/releases/latest) |
| OpenSUSE | `aarch64`, `armhfp`, `i686`, `ppc64`, `ppc64le`, `x86_64` | [`rpm`](https://github.com/twpayne/chezmoi/releases/latest) |
| Ubuntu | `amd64`, `arm64`, `armel`, `i386`, `ppc64`, `ppc64le` | [`deb`](https://github.com/twpayne/chezmoi/releases/latest) |
+13
View File
@@ -0,0 +1,13 @@
                                                                              
  DISTRIBUTION │ ARCHITECTURES │ PACKAGE                    
 ───────────────┼────────────────────────────────┼──────────                   
  Debian │ amd64, arm64, armel, i386, │ deb                    
  │ ppc64, ppc64le │                    
  RedHat │ aarch64, armhfp, i686, ppc64, │ rpm                    
  │ ppc64le, x86_64 │                    
  OpenSUSE │ aarch64, armhfp, i686, ppc64, │ rpm                    
  │ ppc64le, x86_64 │                    
  Ubuntu │ amd64, arm64, armel, i386, │ deb                    
  │ ppc64, ppc64le │                    

+2
View File
@@ -0,0 +1,2 @@
- Navigation
- Familiar shortcuts (arrows, <kbd>~</kbd>, <kbd>-</kbd>, <kbd>@</kbd>), quick reference
+6
View File
@@ -0,0 +1,6 @@
                                                                              
 • Navigation                                                                  
   • Familiar shortcuts (arrows, ~, -, @), quick reference                     
                                                                               
+11
View File
@@ -0,0 +1,11 @@
| Dependency | Installation | Operation |
| --- | --- | --- |
| xdg-open (Linux), open(1) (macOS), cygstart (Cygwin) | base | desktop opener |
| file, coreutils (cp, mv, rm), xargs | base | file type, copy, move and remove |
| tar, (un)zip [atool/bsdtar for more formats] | base | create, list, extract tar, gzip, bzip2, zip |
| archivemount, fusermount(3) | optional | mount, unmount archives |
| sshfs, [rclone](https://rclone.org/), fusermount(3) | optional | mount, unmount remotes |
| trash-cli | optional | trash files (default action: rm) |
| vlock (Linux), bashlock (macOS), lock(1) (BSD) | optional | terminal locker (fallback: [cmatrix](https://github.com/abishekvashok/cmatrix)) |
| advcpmv (Linux) ([integration](https://github.com/jarun/nnn/wiki/Advanced-use-cases#show-cp-mv-progress)) | optional | copy, move progress |
| `$VISUAL` (else `$EDITOR`), `$PAGER`, `$SHELL` | optional | fallback vi, less, sh |
+20
View File
@@ -0,0 +1,20 @@
                                                                              
  DEPENDENCY │ INSTALLATION │ OPERATION         
 ─────────────────────────────────┼──────────────┼─────────────────────────────────
  xdg-open (Linux), open(1) │ base │ desktop opener              
  (macOS), cygstart (Cygwin) │ │                             
  file, coreutils (cp, mv, rm), │ base │ file type, copy, move and   
  xargs │ │ remove                      
  tar, (un)zip [atool/bsdtar for │ base │ create, list, extract tar,  
  more formats] │ │ gzip, bzip2, zip            
  archivemount, fusermount(3) │ optional │ mount, unmount archives     
  sshfs, rclone, fusermount(3) │ optional │ mount, unmount remotes      
  trash-cli │ optional │ trash files (default action:
  │ │ rm)                         
  vlock (Linux), bashlock │ optional │ terminal locker (fallback:  
  (macOS), lock(1) (BSD) │ │ cmatrix)                    
  advcpmv (Linux) (integration) │ optional │ copy, move progress         
  $VISUAL (else $EDITOR), │ optional │ fallback vi, less, sh       
  $PAGER, $SHELL │ │                             

+1
View File
@@ -0,0 +1 @@
Example: `<some directory>`
+3
View File
@@ -0,0 +1,3 @@
 Example:  <some directory>