Skip to content

Add tests for GPUAdapterInfo.isFallbackAdapter#4303

Merged
beaufortfrancois merged 5 commits intomainfrom
isFallbackAdapter
Mar 26, 2025
Merged

Add tests for GPUAdapterInfo.isFallbackAdapter#4303
beaufortfrancois merged 5 commits intomainfrom
isFallbackAdapter

Conversation

@beaufortfrancois
Copy link
Copy Markdown
Collaborator

Issue: #2356

image

Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)
  • Test have be tested with compatibility mode validation enabled and behave as expected. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located in the test tree.
  • Test descriptions allow a reader to "read only the test plans and evaluate coverage completeness", and accurately reflect the test code.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Helpers and types promote readability and maintainability.

When landing this PR, be sure to make any necessary issue status updates.

@beaufortfrancois
Copy link
Copy Markdown
Collaborator Author

I think I need to wait for #4302 to land to make CI bots happy and I'll rebase.

if (forceFallbackAdapter && !adapter) {
t.skip('No adapter available');
return;
assert(typeof adapter?.info.isFallbackAdapter === 'boolean');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This assert will fail if adapter is null.

I adjusted the logic a bit and also switched to t.expect. PTAL

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for catching! LGTM

FWIW, I would have followed the following pattern.

    if (!adapter) {
      // Failing to create an adapter is only OK when forceFallbackAdapter is true.
      t.expect(forceFallbackAdapter === true);

      // Mark the test as skipped (as long as nothing else failed before this point).
      t.skip('No fallback adapter available');
      return;
    }
    
    t.expect(adapter.info.isFallbackAdapter === Boolean(forceFallbackAdapter));
    await testAdapter(t, adapter);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That makes sense! Feel free to apply that and land

@beaufortfrancois beaufortfrancois merged commit e352b0a into main Mar 26, 2025
1 check passed
@beaufortfrancois beaufortfrancois deleted the isFallbackAdapter branch March 26, 2025 07:18
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.

2 participants