Skip to content

🧪 testing improvement description#51

Open
savvides wants to merge 1 commit into
mainfrom
test-slugify-6863284810201051258
Open

🧪 testing improvement description#51
savvides wants to merge 1 commit into
mainfrom
test-slugify-6863284810201051258

Conversation

@savvides

@savvides savvides commented Jun 6, 2026

Copy link
Copy Markdown
Owner

🎯 What: Adds missing unit tests for the string manipulation logic in bin/idstack-slugify.
📊 Coverage: The new test script (test/test-slugify.sh) handles edge cases (leading/trailing/multiple hyphens), special characters, NFKD-folding of Unicode/non-ASCII characters, explicit and implicit standard input pipelining, empty strings, and absence-of-TTY behaviors.
Result: Test assertions are centralized, and idstack-slugify pure string functions are thoroughly validated, increasing codebase test coverage.


PR created automatically by Jules for task 6863284810201051258 started by @savvides

- Creates `test/test-slugify.sh` with comprehensive test coverage including standard strings, empty strings, multi-hyphen behaviors, special characters, unicode strings, implicit/explicit standard inputs, and terminal detections.
- Replaces scattered inline slugify assertions in `test/smoke-test.sh` with a call to the new test script to reduce redundancy.

Co-authored-by: savvides <1580637+savvides@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request extracts the inline slugify tests from test/smoke-test.sh into a dedicated unit test suite in test/test-slugify.sh, expanding test coverage to include various edge cases, unicode handling, and input methods. Feedback on the new test script includes resolving a Python compatibility issue with os.waitstatus_to_exitcode on older Python versions, using pwd -P to handle symbolic links robustly, and avoiding toggling set -e globally inside a function by using an OR list to capture exit codes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread test/test-slugify.sh
# The tool checks [ -t 0 ] to detect if it's connected to a terminal.
# We simulate a terminal using python's pty module.
if command -v python3 >/dev/null 2>&1; then
assert_exit_code "no input given (exit 3)" "python3 -c 'import sys, os, pty, subprocess; pid, fd = pty.fork(); sys.exit(subprocess.call([\"$SLUGIFY\"])) if pid == 0 else sys.exit(os.waitstatus_to_exitcode(os.waitpid(pid, 0)[1]))'" 3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The python command uses os.waitstatus_to_exitcode, which was introduced in Python 3.9. This will cause the test suite to fail with an AttributeError on systems running older Python versions (such as Python 3.8, which is the default on Ubuntu 20.04 LTS).

Using os.execv and os.WEXITSTATUS is fully compatible with all Python 3 versions and is cleaner.

Suggested change
assert_exit_code "no input given (exit 3)" "python3 -c 'import sys, os, pty, subprocess; pid, fd = pty.fork(); sys.exit(subprocess.call([\"$SLUGIFY\"])) if pid == 0 else sys.exit(os.waitstatus_to_exitcode(os.waitpid(pid, 0)[1]))'" 3
assert_exit_code "no input given (exit 3)" "python3 -c 'import os, pty, sys; pid, fd = pty.fork(); os.execv(\"$SLUGIFY\", [\"$SLUGIFY\"]) if pid == 0 else sys.exit(os.WEXITSTATUS(os.waitpid(pid, 0)[1]))'" 3

Comment thread test/test-slugify.sh
FAIL=0
TOTAL=0

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure robustness when the repository or test scripts are accessed via symbolic links, it is recommended to use pwd -P instead of pwd. This resolves the physical directory structure and maintains consistency with how IDSTACK_DIR is resolved in test/smoke-test.sh.

Suggested change
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

Comment thread test/test-slugify.sh
Comment on lines +42 to +45
set +e
eval "$command" >/dev/null 2>&1
local code=$?
set -e

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Toggling set -e and set +e globally within a function can be risky if the function exits prematurely or if there are other side effects. Instead, you can safely capture the exit code of the command without triggering set -e by executing it as part of an || (OR) list.

Suggested change
set +e
eval "$command" >/dev/null 2>&1
local code=$?
set -e
local code=0
eval "$command" >/dev/null 2>&1 || code=$?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant