From 52b4215b5207b489d1c4b7f2ba13064a88306b11 Mon Sep 17 00:00:00 2001 From: Simon Halvorsen Date: Fri, 31 Jul 2026 15:30:48 +0200 Subject: [PATCH] Changed name of test and made prompt detect os version differences (CtrlD/CtrlZ) Signed-off-by: Simon Halvorsen --- cfbs/prompts.py | 6 ++++-- ...put_multilinestring.sh => 059_input_string_multiline.sh} | 4 ++-- .../example-cfbs.json | 0 .../expected-augment.json | 0 tests/shell/all.sh | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) rename tests/shell/{059_input_multilinestring.sh => 059_input_string_multiline.sh} (79%) rename tests/shell/{059_input_multilinestring => 059_input_string_multiline}/example-cfbs.json (100%) rename tests/shell/{059_input_multilinestring => 059_input_string_multiline}/expected-augment.json (100%) diff --git a/cfbs/prompts.py b/cfbs/prompts.py index 5212016a..12e5c01a 100644 --- a/cfbs/prompts.py +++ b/cfbs/prompts.py @@ -1,3 +1,5 @@ +import sys + YES_NO_CHOICES = ("yes", "y", "no", "n") @@ -53,8 +55,8 @@ def prompt_user_multiline(non_interactive: bool, prompt: str, default=None): print(prompt) print( - "(Enter one or more lines of text, then finish with double newline or Ctrl+D" - " (Ctrl+Z followed by Enter on Windows))" + "(Enter one or more lines of text, then finish with double newline or %s)" + % ("Ctrl+Z followed by enter" if sys.platform.startswith("win") else "Ctrl+D") ) lines = [] diff --git a/tests/shell/059_input_multilinestring.sh b/tests/shell/059_input_string_multiline.sh similarity index 79% rename from tests/shell/059_input_multilinestring.sh rename to tests/shell/059_input_string_multiline.sh index e02442ec..dcf2cd05 100644 --- a/tests/shell/059_input_multilinestring.sh +++ b/tests/shell/059_input_string_multiline.sh @@ -6,7 +6,7 @@ cd ./tmp/ touch cfbs.json && rm cfbs.json rm -rf .git rm -rf create-single-file-with-content -cp ../shell/059_input_multilinestring/example-cfbs.json cfbs.json +cp ../shell/059_input_string_multiline/example-cfbs.json cfbs.json cfbs --non-interactive input create-single-file-with-content grep '"type": "string-multiline"' create-single-file-with-content/input.json @@ -14,4 +14,4 @@ grep '"default": "Hello CFEngine!\\nBye CFEngine!"' create-single-file-with-cont grep '"response": "Hello CFEngine!\\nBye CFEngine!"' create-single-file-with-content/input.json cfbs render-input create-single-file-with-content create-single-file-with-content/input.json actual.output -diff actual.output ../shell/059_input_multilinestring/expected-augment.json +diff actual.output ../shell/059_input_string_multiline/expected-augment.json diff --git a/tests/shell/059_input_multilinestring/example-cfbs.json b/tests/shell/059_input_string_multiline/example-cfbs.json similarity index 100% rename from tests/shell/059_input_multilinestring/example-cfbs.json rename to tests/shell/059_input_string_multiline/example-cfbs.json diff --git a/tests/shell/059_input_multilinestring/expected-augment.json b/tests/shell/059_input_string_multiline/expected-augment.json similarity index 100% rename from tests/shell/059_input_multilinestring/expected-augment.json rename to tests/shell/059_input_string_multiline/expected-augment.json diff --git a/tests/shell/all.sh b/tests/shell/all.sh index 22d21c2f..152bc363 100644 --- a/tests/shell/all.sh +++ b/tests/shell/all.sh @@ -102,7 +102,7 @@ run_test tests/shell/055_render_input_two_variables.sh run_test tests/shell/056_render_input_list.sh run_test tests/shell/057_render_input_no_response.sh run_test tests/shell/058_render_input_fail.sh -run_test tests/shell/059_input_multilinestring.sh +run_test tests/shell/059_input_string_multiline.sh # Summary _suite_end=$(date +%s)