From 41ac212713988116e0fa5353da87d6815de2f22c Mon Sep 17 00:00:00 2001 From: Jan Meis Date: Wed, 8 Dec 2021 16:03:24 +0100 Subject: [PATCH 1/9] Fixed a bug that made it impossible to render tables whenever test cases fail. Before, pdflatex would fail with error message "Extra alignment tab has been changed to \cr. `expected`: TRUE & Fail &". --- R/evaluate_test_code.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/evaluate_test_code.R b/R/evaluate_test_code.R index eae0884..f63ef4f 100644 --- a/R/evaluate_test_code.R +++ b/R/evaluate_test_code.R @@ -56,6 +56,9 @@ vt_kable_test_code_results <- function(results, format = vt_render_to()) { x <- results[, c("Test", "Results", "Pass_Fail")] colnames(x) <- c("Test", "Results", "Pass/Fail") + if (nrow(x) > 0) { + x$Results <- gsub("\n","",x$Results) + } t <- kable(x,format = format) From aa819f7e3a18a17d69e17be084e101a2ce14c5d7 Mon Sep 17 00:00:00 2001 From: "Lukas D. Sauer" Date: Tue, 13 Sep 2022 11:00:59 +0200 Subject: [PATCH 2/9] Non-integer requirement name in coverage matrix Fixing the requirement title in the coverage matrix for requirement names that are non-integers, such as "01" instead of "1". This is a quick fix. It would be even better if the actual requirement was used, as in the risk assessment matrix. --- R/coverage-matrix.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/coverage-matrix.R b/R/coverage-matrix.R index 80af6ea..fba0c9e 100644 --- a/R/coverage-matrix.R +++ b/R/coverage-matrix.R @@ -50,8 +50,8 @@ vt_scrape_coverage_matrix <- function(type = c("long", "wide"), # req_title uses only first numeric position out$req_title <- factor(out$req_title, levels = paste0("Requirement ", - sort(as.numeric(unique(unlist(lapply(strsplit(out$req_title, split = " "), - function(x){x[2]}))))))) + sort(unique(unlist(lapply(strsplit(out$req_title, split = " "), + function(x){x[2]})))))) out[order(out$req_title),] } From d7fe8338a3034f3df32ce081568c5fbec214275d Mon Sep 17 00:00:00 2001 From: Jan Meis Date: Fri, 14 Oct 2022 14:42:50 +0200 Subject: [PATCH 3/9] hopefully get longtable to work --- R/evaluate_test_code.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/evaluate_test_code.R b/R/evaluate_test_code.R index f63ef4f..f932c61 100644 --- a/R/evaluate_test_code.R +++ b/R/evaluate_test_code.R @@ -60,7 +60,7 @@ vt_kable_test_code_results <- function(results, format = vt_render_to()) { x$Results <- gsub("\n","",x$Results) } - t <- kable(x,format = format) + t <- kable(x, format = format, longtable = TRUE) if(nrow(results) > 0){ t <- column_spec(t, 2:3, width = "10em") From 1e1978394dab6763d8b3416f381c2c18396ffabe Mon Sep 17 00:00:00 2001 From: "Lukas D. Sauer" Date: Wed, 7 Dec 2022 10:11:38 +0100 Subject: [PATCH 4/9] Update evaluate_test_code.R Incorporating the bug fix for tests that failed, see https://github.com/phuse-org/valtools/pull/222/files --- R/evaluate_test_code.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/evaluate_test_code.R b/R/evaluate_test_code.R index eae0884..45ad66e 100644 --- a/R/evaluate_test_code.R +++ b/R/evaluate_test_code.R @@ -57,7 +57,7 @@ vt_kable_test_code_results <- function(results, format = vt_render_to()) { x <- results[, c("Test", "Results", "Pass_Fail")] colnames(x) <- c("Test", "Results", "Pass/Fail") - t <- kable(x,format = format) + t <- kable(x, format = format, longtable = TRUE) if(nrow(results) > 0){ t <- column_spec(t, 2:3, width = "10em") From 9c2cd39631c76db88cdb15ad05b17eb99684f8db Mon Sep 17 00:00:00 2001 From: Jan Meis Date: Wed, 7 Dec 2022 14:51:12 +0100 Subject: [PATCH 5/9] Escape unicode --- R/evaluate_test_code.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/evaluate_test_code.R b/R/evaluate_test_code.R index f932c61..08e21e3 100644 --- a/R/evaluate_test_code.R +++ b/R/evaluate_test_code.R @@ -57,7 +57,7 @@ vt_kable_test_code_results <- function(results, format = vt_render_to()) { x <- results[, c("Test", "Results", "Pass_Fail")] colnames(x) <- c("Test", "Results", "Pass/Fail") if (nrow(x) > 0) { - x$Results <- gsub("\n","",x$Results) + x$Results <- gsub("\n","", gsub("\a|\033","", x$Results)) } t <- kable(x, format = format, longtable = TRUE) From e3ab236c80c5af0d53469d6570614b46c3ddf1d8 Mon Sep 17 00:00:00 2001 From: "Lukas D. Sauer" Date: Thu, 27 Apr 2023 11:07:25 +0200 Subject: [PATCH 6/9] Options for compress rows in the coverage matrix --- R/coverage-matrix.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/coverage-matrix.R b/R/coverage-matrix.R index fba0c9e..f8b859f 100644 --- a/R/coverage-matrix.R +++ b/R/coverage-matrix.R @@ -127,15 +127,15 @@ vt_scrape_coverage_matrix <- function(type = c("long", "wide"), #' @importFrom knitr kable #' @importFrom kableExtra kable_styling collapse_rows add_header_above #' @export -vt_kable_coverage_matrix <- function(x, format = vt_render_to()){ +vt_kable_coverage_matrix <- function(x, format = vt_render_to(), ...){ switch(attr(x, "table_type"), - "long" = kable_cov_matrix_long(x, format = format), - "wide" = kable_cov_matrix_wide(x, format = format)) + "long" = kable_cov_matrix_long(x, format = format, ...), + "wide" = kable_cov_matrix_wide(x, format = format, ...)) } -kable_cov_matrix_long <- function(x, format = vt_render_to()){ +kable_cov_matrix_long <- function(x, format = vt_render_to(), ...){ this_col_names <- c("Requirement Name", "Requirement ID", "Test Case Name", "Test Cases") if(all(x$deprecate == "")){ x <- x[,-which(names(x) == "deprecate")] @@ -149,7 +149,7 @@ kable_cov_matrix_long <- function(x, format = vt_render_to()){ out_tab <- kable_styling(out_tab, font_size = 6) out_tab <- column_spec(out_tab, 1, border_left = TRUE) out_tab <- column_spec(out_tab, ncol(x), border_right = TRUE) - out_tab <- collapse_rows(out_tab, c(1, 3)) + out_tab <- collapse_rows(out_tab, c(1, 3), ...) out_tab } From ef2fa60c042c1e38967f22716bdceb4c854d1143 Mon Sep 17 00:00:00 2001 From: "Lukas D. Sauer" Date: Thu, 27 Apr 2023 11:17:35 +0200 Subject: [PATCH 7/9] Manual LaTeX options for authorship scrapers --- R/scrape_authorship.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/scrape_authorship.R b/R/scrape_authorship.R index 9232ad3..46cfa0c 100644 --- a/R/scrape_authorship.R +++ b/R/scrape_authorship.R @@ -136,7 +136,8 @@ vt_scrape_function_editors <- function(tags = c("editor", "editDate", "export") #' @importFrom knitr kable #' @rdname scraping #' -vt_kable_requirement_editors <- function(x,format = vt_render_to()){ +vt_kable_requirement_editors <- function(x,format = vt_render_to(), + latex_options = "hold_position"){ all_colnames <- c(requirements = "Requirement ID", editor = "Editor", editDate = "Edit Date") @@ -145,7 +146,7 @@ vt_kable_requirement_editors <- function(x,format = vt_render_to()){ col.names = all_colnames) t <- column_spec(t, 1, border_left = TRUE) t <- column_spec(t, ncol(x), border_right = TRUE) - t <- kable_styling(t, latex_options = "hold_position") + t <- kable_styling(t, latex_options) t } @@ -178,7 +179,8 @@ vt_kable_function_editors <- function(x,format = vt_render_to()){ #' @importFrom knitr kable #' @rdname scraping #' -vt_kable_test_case_editors <- function(x,format = vt_render_to()){ +vt_kable_test_case_editors <- function(x,format = vt_render_to(), + latex_options = "hold_position"){ all_colnames <- c(test_cases = "Test Case ID", editor = "Editor", editDate = "Edit Date") @@ -187,7 +189,7 @@ vt_kable_test_case_editors <- function(x,format = vt_render_to()){ col.names = all_colnames) t <- column_spec(t, 1, border_left = TRUE) t <- column_spec(t, length(all_colnames), border_right = TRUE) - t <- kable_styling(t, latex_options = "hold_position") + t <- kable_styling(t, latex_options) t } From e43c0fae73d1f891913aacc07f96984adc165737 Mon Sep 17 00:00:00 2001 From: "Lukas D. Sauer" Date: Thu, 27 Apr 2023 11:35:28 +0200 Subject: [PATCH 8/9] Bug fix --- R/scrape_authorship.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/scrape_authorship.R b/R/scrape_authorship.R index 46cfa0c..a529f8c 100644 --- a/R/scrape_authorship.R +++ b/R/scrape_authorship.R @@ -146,7 +146,7 @@ vt_kable_requirement_editors <- function(x,format = vt_render_to(), col.names = all_colnames) t <- column_spec(t, 1, border_left = TRUE) t <- column_spec(t, ncol(x), border_right = TRUE) - t <- kable_styling(t, latex_options) + t <- kable_styling(t, latex_options = latex_options) t } @@ -189,7 +189,7 @@ vt_kable_test_case_editors <- function(x,format = vt_render_to(), col.names = all_colnames) t <- column_spec(t, 1, border_left = TRUE) t <- column_spec(t, length(all_colnames), border_right = TRUE) - t <- kable_styling(t, latex_options) + t <- kable_styling(t, latex_options = latex_options) t } From 68dc43fe3cce53bc7de999121d4e650213efb7b8 Mon Sep 17 00:00:00 2001 From: "Lukas D. Sauer" Date: Thu, 27 Apr 2023 13:08:42 +0200 Subject: [PATCH 9/9] One more authorship scraper --- R/scrape_authorship.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/R/scrape_authorship.R b/R/scrape_authorship.R index a529f8c..58eeb65 100644 --- a/R/scrape_authorship.R +++ b/R/scrape_authorship.R @@ -198,7 +198,8 @@ vt_kable_test_case_editors <- function(x,format = vt_render_to(), #' @importFrom knitr kable #' @rdname scraping #' -vt_kable_test_code_editors <- function(x,format = vt_render_to()){ +vt_kable_test_code_editors <- function(x, format = vt_render_to(), + latex_options = "hold_position", ...){ all_colnames <- c(test_code = "Test Code ID", editor = "Editor", editDate = "Edit Date") @@ -212,9 +213,12 @@ vt_kable_test_code_editors <- function(x,format = vt_render_to()){ t <- kable(x[, names(all_colnames)], format = format, booktabs = FALSE, - col.names = all_colnames) + longtable = TRUE, + col.names = all_colnames + ) t <- column_spec(t, 1, border_left = TRUE) t <- column_spec(t, ncol(x), border_right = TRUE) - t <- kable_styling(t, latex_options = "hold_position") + t <- kable_styling(t, latex_options = latex_options) + t <- collapse_rows(t, c(2, 3), ...) t }