Created
October 19, 2019 05:56
-
-
Save christopherlam/290a384ff72f2f912bce579c5e8438c1 to your computer and use it in GitHub Desktop.
patch to extricate stylesheets from test-report-html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gnucash/report/report-system/test/test-report-html.scm b/gnucash/report/report-system/test/test-report-html.scm | |
index 5c672690c..925d26c35 100644 | |
--- a/gnucash/report/report-system/test/test-report-html.scm | |
+++ b/gnucash/report/report-system/test/test-report-html.scm | |
@@ -4,11 +4,12 @@ | |
(use-modules (gnucash engine test test-extras)) | |
(use-modules (gnucash report report-system)) | |
+(use-modules (gnucash utilities)) | |
(use-modules (gnucash report report-system test test-extras)) | |
-(use-modules (gnucash report stylesheets)) | |
(use-modules (srfi srfi-64)) | |
(use-modules (ice-9 pretty-print)) | |
(use-modules (sxml simple)) | |
+(use-modules (sxml xpath)) | |
(use-modules (gnucash engine test srfi64-extras)) | |
(use-modules (system vm coverage)) | |
@@ -886,16 +887,21 @@ HTML Document Title</title></head><body></body>\n\ | |
(define (test-gnc:make-html-acct-table/env/accts) | |
+ (define (strip-generics str) | |
+ (let* ((str (gnc:substring-replace str "<string>" "")) | |
+ (str (gnc:substring-replace str "<number>" "")) | |
+ (str (gnc:substring-replace str "<boolean>" "")) | |
+ (str (gnc:substring-replace str "<generic>" ""))) | |
+ str)) | |
+ | |
;; create html-document, add table, render, convert to sxml | |
(define (table->sxml table prefix) | |
- (let* ((doc (gnc:make-html-document))) | |
- (gnc:html-document-set-style-sheet! doc (gnc:html-style-sheet-find "Default")) | |
+ (let ((doc (gnc:make-html-document))) | |
(gnc:html-document-add-object! doc table) | |
- (let ((render (gnc:html-document-render doc))) | |
- (with-output-to-file (format #f "/tmp/html-acct-table-~a.html" prefix) | |
- (lambda () | |
- (display render))) | |
- (xml->sxml render | |
+ (let ((render (string-concatenate | |
+ (gnc:html-document-tree-collapse | |
+ (gnc:html-table-render table doc))))) | |
+ (xml->sxml (strip-generics render) | |
#:trim-whitespace? #t | |
#:entities '((nbsp . "\xa0") | |
(ndash . "")))))) | |
@@ -915,9 +921,10 @@ HTML Document Title</title></head><body></body>\n\ | |
(gnc:html-table-add-account-balances table acct-table '()) | |
(let ((sxml (table->sxml table "basic - combo 1"))) | |
(test-equal "gnc:make-html-acct-table/env/accts combo 1" | |
- '("Root" "Asset" "Bank" "GBP Bank" "Wallet" "Liabilities" | |
- "Income" "Income-GBP" "Expenses" "Equity") | |
- (sxml->table-row-col sxml 1 #f 1)))) | |
+ '(" Root" " Asset" " Bank" " GBP Bank" " Wallet" " Liabilities" | |
+ " Income" " Income-GBP" " Expenses" " Equity") | |
+ ((sxpath '(// table // tr // a // *text*)) | |
+ sxml)))) | |
(let* ((table (gnc:make-html-table)) | |
(acct-table (gnc:make-html-acct-table/env/accts | |
@@ -927,9 +934,10 @@ HTML Document Title</title></head><body></body>\n\ | |
(gnc:html-table-add-account-balances table acct-table '()) | |
(let ((sxml (table->sxml table "basic - combo 2"))) | |
(test-equal "gnc:make-html-acct-table/env/accts combo 2" | |
- '("Root" "Asset" "Bank" "GBP Bank" "Wallet" "Liabilities" | |
- "Income" "Income-GBP" "Expenses" "Equity") | |
- (sxml->table-row-col sxml 1 #f 1)))) | |
+ '(" Root" " Asset" " Bank" " GBP Bank" " Wallet" " Liabilities" | |
+ " Income" " Income-GBP" " Expenses" " Equity") | |
+ ((sxpath '(// table // tr // a // *text*)) | |
+ sxml)))) | |
(let* ((table (gnc:make-html-table)) | |
(acct-table (gnc:make-html-acct-table/env/accts | |
@@ -939,6 +947,7 @@ HTML Document Title</title></head><body></body>\n\ | |
(gnc:html-table-add-account-balances table acct-table '()) | |
(let ((sxml (table->sxml table "basic - combo 3"))) | |
(test-equal "gnc:make-html-acct-table/env/accts combo 3" | |
- '("Root" "Asset" "Bank" "GBP Bank" "Wallet" "Liabilities" | |
- "Income" "Income-GBP" "Expenses" "Equity") | |
- (sxml->table-row-col sxml 1 #f 1)))))) | |
+ '(" Root" " Asset" " Bank" " GBP Bank" " Wallet" " Liabilities" | |
+ " Income" " Income-GBP" " Expenses" " Equity") | |
+ ((sxpath '(// table // tr // a // *text*)) | |
+ sxml)))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment