Skip to content

Conversation

@zFernand0
Copy link
Member

@zFernand0 zFernand0 commented Oct 28, 2025

What It Does

  • Adds system tests for zowex ds commands
  • Adds ZNP_TEST_LOG optional env-var to turn ON|OFF any TestLog calls 🙏
  • Adds a ztest.utils.hpp with common functions for zowex tests
  • Moves all zowex ds tests to zowex.ds.test.cpp

How to Test

nr z:test

Review Checklist
I certify that I have:

Additional Comments

@zFernand0 zFernand0 self-assigned this Oct 28, 2025
@zFernand0 zFernand0 added the no-changelog For pull requests that don't require changelogs label Oct 28, 2025
@github-project-automation github-project-automation bot moved this to New Issues in Zowe CLI Squad Oct 28, 2025
@zowe-robot zowe-robot moved this from New Issues to In Progress in Zowe CLI Squad Oct 28, 2025
@zFernand0 zFernand0 changed the base branch from main to feat/test-utils October 28, 2025 14:22
@github-actions
Copy link

github-actions bot commented Oct 28, 2025

Base automatically changed from feat/test-utils to main October 29, 2025 20:44
@dkelosky
Copy link
Collaborator

I know it's early, but can you include:

  • multiple threads accessing the same data set for writing?
  • if resources are released when a thread opens a data set and crashes (but the process remains active)?

const char *debug = getenv("ZNP_TEST_LOG");
if (debug == nullptr || strstr(debug, "ON") != nullptr)
{
pad_nesting(get_nesting());

Check warning

Code scanning / CodeQL

Expression has no effect Warning test

This expression has no effect (because
pad_nesting
has no external side effects).

Copilot Autofix

AI 1 day ago

The recommended fix for this issue, per static analysis guidance, is to explicitly cast the function call expression to void, using (void)pad_nesting(get_nesting());. This documents that it is executed for its side effect only, and clarifies to reviewers and tools that the function’s return value (void) is intentionally ignored. The only change required is to line 414 of native/c/test/ztest.hpp, within the body of test_log, replacing the plain call to pad_nesting(get_nesting()); with (void)pad_nesting(get_nesting());. No imports or other changes are necessary.

Suggested changeset 1
native/c/test/ztest.hpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/native/c/test/ztest.hpp b/native/c/test/ztest.hpp
--- a/native/c/test/ztest.hpp
+++ b/native/c/test/ztest.hpp
@@ -411,7 +411,7 @@
     const char *debug = getenv("ZNP_TEST_LOG");
     if (debug == nullptr || strstr(debug, "ON") != nullptr)
     {
-      pad_nesting(get_nesting());
+      (void)pad_nesting(get_nesting());
       std::cout << "[TEST_INFO] " << message << std::endl;
     }
   }
EOF
@@ -411,7 +411,7 @@
const char *debug = getenv("ZNP_TEST_LOG");
if (debug == nullptr || strstr(debug, "ON") != nullptr)
{
pad_nesting(get_nesting());
(void)pad_nesting(get_nesting());
std::cout << "[TEST_INFO] " << message << std::endl;
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
int execute_command_with_output(const string &command, string &output)
{
output = "";
// TestLog("Running: " + command);

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.

Copilot Autofix

AI 1 day ago

The best way to fix this problem is to remove the commented-out code, as retaining commented-out code leads to code rot and confusion. If the logging functionality is still desired or needed, the author should add a properly enabled logging statement, perhaps with a guard or modern logging mechanism. If it was left for future use or as a suggestion, it should be transformed into a regular code comment, not a commented-out code line.

For minimum intervention and to avoid changing behavior, the fix should be to delete line 38 entirely from native/c/test/ztest.utils.hpp. Only this line must be removed; no imports or other changes are necessary.

Suggested changeset 1
native/c/test/ztest.utils.hpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/native/c/test/ztest.utils.hpp b/native/c/test/ztest.utils.hpp
--- a/native/c/test/ztest.utils.hpp
+++ b/native/c/test/ztest.utils.hpp
@@ -35,7 +35,6 @@
 int execute_command_with_output(const string &command, string &output)
 {
   output = "";
-  // TestLog("Running: " + command);
 
   FILE *pipe = popen((command + " 2>&1").c_str(), "r");
   if (!pipe)
EOF
@@ -35,7 +35,6 @@
int execute_command_with_output(const string &command, string &output)
{
output = "";
// TestLog("Running: " + command);

FILE *pipe = popen((command + " 2>&1").c_str(), "r");
if (!pipe)
Copilot is powered by AI and may make mistakes. Always verify output.
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
31.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog For pull requests that don't require changelogs size/XXL

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants