TESTING.md (2147B)
1 # Testing 2 This file holds notes for testing purposes. 3 4 ## Compile with Debug Symbols 5 To make a build with debug symbols (for example, required to run 6 [Valgrind](#valgrind) below) use the `debug` target: 7 ```bash 8 make debug 9 ``` 10 11 ## Valgrind 12 Use Valgrind on a build with debug symbols to discover memory issues: 13 ```bash 14 mkdir -p tmp-journal 15 make debug 16 valgrind --leak-check=full ./diary tmp-journal/ 2>log.txt 17 ``` 18 19 https://developers.redhat.com/blog/2021/04/23/valgrind-memcheck-different-ways-to-lose-your-memory#generating_a_leak_summary 20 21 Don't use `--show-leak-kinds=all` with Ncurses: 22 https://invisible-island.net/ncurses/ncurses.faq.html#config_leaks 23 24 ## Compile with Clang Compiler 25 As pointed out in [#82](https://github.com/in0rdr/diary/issues/82) the clang 26 compiler is a lot more useful when it comes to debugging. 27 28 To compile the program with clang: 29 ``` 30 make CC=clang 31 ``` 32 33 ## Send stderr to File 34 35 Send stderr to a file for debugging: 36 ```bash 37 diary 2>log.txt 38 ``` 39 40 Or to `/dev/null` to ignore the debug messages flickering on the screen: 41 ```bash 42 diary 2>/dev/null 43 ``` 44 45 ## Render Documentation / Man Page 46 ### Generate Runoff 47 Install [scdoc](https://git.sr.ht/~sircmpwn/scdoc). 48 49 Generate the "runoff" text with `scdoc` from the Markdown like `.scd` file: 50 ```bash 51 SOURCE_DATE_EPOCH=$(date +%s) scdoc < diary.1.scd > diary.1 52 ``` 53 54 ### View Manpage in Terminal 55 Generate plain text from "runoff" text: 56 ```bash 57 tbl diary.1 | nroff -man | less 58 ``` 59 60 ### `mandoc` HTML (Preferred) 61 Install [`mandoc`](https://en.wikipedia.org/wiki/Mandoc) >= [1.14.6 (helps to 62 format paragraphs with CSS)](https://mandoc.bsd.lv/NEWS): 63 ```bash 64 curl -sO https://mandoc.bsd.lv/snapshots/mandoc-1.14.6.tar.gz 65 tar -xf mandoc-1.14.6.tar.gz 66 cd mandoc-1.14.6 67 ./configure 68 make 69 ``` 70 71 Generate HTML page from runoff: 72 ```bash 73 ../../mandoc-1.14.6/mandoc -Thtml -O style=style.css diary.1 > diary.1.html 74 ``` 75 76 ### `groff` HTML (Alternative) 77 Limitation: `groff` produces unstyled output (no CSS). 78 79 Install [`groff`](https://www.gnu.org/software/groff): 80 ```bash 81 sudo apt-get install groff 82 ``` 83 84 Generate HTML file (`-t` for `tbl`): 85 ```bash 86 groff -t -mandoc -Thtml diary.1 > diary.1.html 87 ```