Skip to content

skip ScalarFunction test on Windows platform.#1139

Merged
suketa merged 1 commit intomainfrom
skip_windows_ci
Mar 12, 2026
Merged

skip ScalarFunction test on Windows platform.#1139
suketa merged 1 commit intomainfrom
skip_windows_ci

Conversation

@suketa
Copy link
Owner

@suketa suketa commented Mar 12, 2026

Summary by CodeRabbit

  • Tests
    • Updated test configurations for improved cross-platform compatibility and code quality maintenance.

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

Updates test file to add Windows-specific skips for scalar function tests and includes RuboCop Metrics/AbcSize suppression annotations across multiple test methods without altering test logic.

Changes

Cohort / File(s) Summary
Test Infrastructure Updates
test/duckdb_test/scalar_function_test.rb
Added Windows-specific test skips (skip conditions for Windows platform detection) and expanded RuboCop suppression flags by adding Metrics/AbcSize to multiple test method declarations (20+ methods updated with consistent annotation pattern).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • #1112: Also modifies test/duckdb_test/scalar_function_test.rb to add Windows-specific skips for test exclusions.
  • #1066: Touches the same test_scalar_function_with_two_parameters method with related changes.
  • #1067: Modifies scalar function test methods including test_scalar_function_with_null_input in the same test file.

Poem

🐰 Windows be skipped, lint warnings dismissed,
Our fluffy test suite, no longer upset,
AbcSize suppressed with a hop and a twist,
Platform-aware testing we'll never forget! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'skip ScalarFunction test on Windows platform' directly describes the main change—adding Windows-specific skips to ScalarFunction tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch skip_windows_ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/duckdb_test/scalar_function_test.rb (1)

140-158: Consider extracting the scalar-function happy-path setup.

Adding Metrics/AbcSize here is a sign that the register/query setup is getting too repetitive. A small helper for SET threads=1, parameter registration, and @con.register_scalar_function would shrink these tests instead of widening inline RuboCop suppressions.

♻️ Possible helper shape
private

def register_scalar_function(name:, return_type:, parameter_types: [], &block)
  `@con.execute`('SET threads=1')

  sf = DuckDB::ScalarFunction.new
  sf.name = name
  Array(parameter_types).each { |type| sf.add_parameter(type) }
  sf.return_type = return_type
  sf.set_function(&block)

  `@con.register_scalar_function`(sf)
end

Then this test becomes:

register_scalar_function(
  name: 'add_nums',
  return_type: DuckDB::LogicalType::INTEGER,
  parameter_types: [DuckDB::LogicalType::INTEGER, DuckDB::LogicalType::INTEGER]
) { |a, b| a + b }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/duckdb_test/scalar_function_test.rb` around lines 140 - 158, Extract the
repeated scalar-function setup into a private helper (e.g.,
register_scalar_function) and use it from
test_scalar_function_with_two_parameters: implement a helper that executes 'SET
threads=1', constructs a DuckDB::ScalarFunction, sets sf.name, iterates
Array(parameter_types) to call sf.add_parameter for each, sets sf.return_type,
calls sf.set_function with the provided block, and calls
`@con.register_scalar_function`(sf); then replace the inline setup in
test_scalar_function_with_two_parameters with a call to
register_scalar_function(name: 'add_nums', return_type:
DuckDB::LogicalType::INTEGER, parameter_types: [DuckDB::LogicalType::INTEGER,
DuckDB::LogicalType::INTEGER]) { |a, b| a + b } and remove the Metrics/AbcSize
suppression.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/duckdb_test/scalar_function_test.rb`:
- Around line 57-59: The test method
test_register_scalar_function_raises_error_without_single_thread should be
skipped on Windows like test_register_scalar_function: add the same guard line
"skip 'Scalar functions with Ruby test' if Gem.win_platform?" at the start of
the test_register_scalar_function_raises_error_without_single_thread method so
the Ruby callback-registration error assertions (the calls to
`@con.register_scalar_function`(sf) and the assert_match checks for
/single-threaded execution/ and /SET threads=1/) are not run on Windows where
messages differ.

---

Nitpick comments:
In `@test/duckdb_test/scalar_function_test.rb`:
- Around line 140-158: Extract the repeated scalar-function setup into a private
helper (e.g., register_scalar_function) and use it from
test_scalar_function_with_two_parameters: implement a helper that executes 'SET
threads=1', constructs a DuckDB::ScalarFunction, sets sf.name, iterates
Array(parameter_types) to call sf.add_parameter for each, sets sf.return_type,
calls sf.set_function with the provided block, and calls
`@con.register_scalar_function`(sf); then replace the inline setup in
test_scalar_function_with_two_parameters with a call to
register_scalar_function(name: 'add_nums', return_type:
DuckDB::LogicalType::INTEGER, parameter_types: [DuckDB::LogicalType::INTEGER,
DuckDB::LogicalType::INTEGER]) { |a, b| a + b } and remove the Metrics/AbcSize
suppression.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c95ed9c1-1ed2-4bd3-9d9f-909a59db97b3

📥 Commits

Reviewing files that changed from the base of the PR and between b299261 and a24b580.

📒 Files selected for processing (1)
  • test/duckdb_test/scalar_function_test.rb

Comment on lines 57 to +59
def test_register_scalar_function
skip 'Scalar functions with Ruby test' if Gem.win_platform?

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
from pathlib import Path
import re

text = Path("test/duckdb_test/scalar_function_test.rb").read_text()
pattern = re.compile(r'^\s*def\s+(test_[^\s(]+).*?(?=^\s*def\s+|\Z)', re.M | re.S)

for match in pattern.finditer(text):
    name = match.group(1)
    body = match.group(0)
    if ("set_function" in body or "register_scalar_function" in body) and "Gem.win_platform?" not in body:
        print(name)
PY

Repository: suketa/ruby-duckdb

Length of output: 144


🏁 Script executed:

cd test/duckdb_test && sed -n '1,100p' scalar_function_test.rb | cat -n

Repository: suketa/ruby-duckdb

Length of output: 3393


🏁 Script executed:

# Extract the two unguarded tests
cd test/duckdb_test && python3 - <<'PYEOF'
from pathlib import Path
import re

text = Path("scalar_function_test.rb").read_text()
lines = text.split('\n')

# Find line numbers for both tests
pattern = re.compile(r'^\s*def\s+(test_set_function|test_register_scalar_function_raises_error_without_single_thread)')
for i, line in enumerate(lines, 1):
    if pattern.search(line):
        print(f"Found '{pattern.search(line).group(1)}' at line {i}")

# Extract full test_set_function (should be around line 17)
print("\n=== test_set_function ===")
for i in range(16, 75):
    print(f"{i+1:3d} | {lines[i]}")

# Extract full test_register_scalar_function_raises_error_without_single_thread (should be around line 75)
print("\n=== test_register_scalar_function_raises_error_without_single_thread ===")
for i in range(74, 95):
    print(f"{i+1:3d} | {lines[i]}")
PYEOF

Repository: suketa/ruby-duckdb

Length of output: 3039


🏁 Script executed:

# Get the full content with line numbers for context
cd test/duckdb_test && wc -l scalar_function_test.rb

Repository: suketa/ruby-duckdb

Length of output: 89


🏁 Script executed:

# Let's look at lines around the two unguarded tests
cd test/duckdb_test && sed -n '17,100p' scalar_function_test.rb | cat -n

Repository: suketa/ruby-duckdb

Length of output: 3022


Add Windows skip to test_register_scalar_function_raises_error_without_single_thread.

This test at lines 75-88 calls @con.register_scalar_function(sf) and asserts the error message matches /single-threaded execution/ and /SET threads=1/. If Ruby callback registration is not supported on Windows, the error will be raised but with a different message, causing the assert_match assertions to fail. Add skip 'Scalar functions with Ruby test' if Gem.win_platform? to the beginning of this test to match the guard pattern used in test_register_scalar_function.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/duckdb_test/scalar_function_test.rb` around lines 57 - 59, The test
method test_register_scalar_function_raises_error_without_single_thread should
be skipped on Windows like test_register_scalar_function: add the same guard
line "skip 'Scalar functions with Ruby test' if Gem.win_platform?" at the start
of the test_register_scalar_function_raises_error_without_single_thread method
so the Ruby callback-registration error assertions (the calls to
`@con.register_scalar_function`(sf) and the assert_match checks for
/single-threaded execution/ and /SET threads=1/) are not run on Windows where
messages differ.

@suketa suketa merged commit 429d306 into main Mar 12, 2026
41 checks passed
@suketa suketa deleted the skip_windows_ci branch March 12, 2026 12:16
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