From 318396487ac70835b250c7d8edd6faed075a91a1 Mon Sep 17 00:00:00 2001 From: Wes Hinsley Date: Mon, 8 Jul 2024 17:20:21 +0100 Subject: [PATCH] Don't print secret env --- R/task.R | 8 ++------ tests/testthat/test-task.R | 11 ++++++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/R/task.R b/R/task.R index ae89fd7a..d601f79e 100644 --- a/R/task.R +++ b/R/task.R @@ -679,12 +679,8 @@ print_info_data <- function(data) { } cli::cli_li("Environment: {data$environment}") if (NROW(data$envvars) > 0) { - cli::cli_li("Environment variables:") - env_vars_ul <- cli::cli_ul() - for (n in seq_along(data$envvars$name)) { - cli::cli_li("{data$envvars$name[n]} = {data$envvars$value[n]}") - } - cli::cli_end(env_vars_ul) + data$envvars$value[data$envvars$secret] <- "********" + cli::cli_dl(items = set_names(data$envvars$value, data$envvars$name)) } if (!is.null(data$path) && data$path != ".") { cli::cli_li("Relative path: {data$path}") diff --git a/tests/testthat/test-task.R b/tests/testthat/test-task.R index 8f1998b2..9361ef0b 100644 --- a/tests/testthat/test-task.R +++ b/tests/testthat/test-task.R @@ -528,12 +528,13 @@ test_that("can print information about task data for expression-based tasks", { data4 <- data data4$envvars <- hipercow_envvars(X = "x", Y = "y", "Z" = "z") + data4$envvars$secret[data4$envvars$name == "Z"] <- TRUE msg4 <- capture_messages(print_info_data(data4)) - expect_length(msg4, 8) - expect_match(msg4[[5]], "Environment variables:") - expect_match(msg4[[6]], "X = x") - expect_match(msg4[[7]], "Y = y") - expect_match(msg4[[8]], "Z = z") + expect_length(msg4, 7) + expect_match(msg4[[4]], "Environment: default") + expect_match(msg4[[5]], "X: x") + expect_match(msg4[[6]], "Y: y") + expect_match(msg4[[7]], "Z: \\*\\*\\*\\*\\*\\*") expect_equal(msg4[1:4], msg) })