Skip to content

no longer possible to run a single test file when it includes another #4850

@khera

Description

@khera

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I use pg_tap to test my DB functionality. There are 15 files, and all of them need some common variables to be set so I have a shared file to set them.

At the top of each file I include the constants file relative to the current directory:

\ir ./testing_constants.sql

Up until recently, this worked great for running all tests plus running individual tests. Now I cannot run individual tests. I haven't tried this in a long while, but I think it corresponds to the time the test suite started printing the full file paths instead of just the relative file paths as it runs.

To Reproduce

Create two test scripts, one of which just includes the other using the \ir command. Try to run just the one that includes the other. In my case:

% npx supabase db test supabase/tests/supabase/storage_object_operations.sql
Connecting to local database...
psql:/Users/vivek/Work/my-app/supabase/tests/supabase/storage_object_operations.sql:5: error: /Users/vivek/Work/my-app/supabase/tests/supabase/testing_constants.sql: No such file or directory
/Users/vivek/Work/my-app/supabase/tests/supabase/storage_object_operations.sql ..
Dubious, test returned 3 (wstat 768, 0x300)
No subtests run

Test Summary Report
-------------------
/Users/vivek/Work/my-app/supabase/tests/supabase/storage_object_operations.sql (Wstat: 768 (exited 3) Tests: 0 Failed: 0)
  Non-zero exit status: 3
  Parse errors: No plan found in TAP output
Files=1, Tests=0,  0 wallclock secs ( 0.01 usr +  0.00 sys =  0.01 CPU)
Result: FAIL
error running container: exit 1
Try rerunning the command with --debug to troubleshoot the error.

I can run the test script that loads the constants just fine, since it does not include any other files.

% npx supabase db test supabase/tests/supabase/testing_constants.sql
Connecting to local database...
/Users/vivek/Work/my-app/supabase/tests/supabase/testing_constants.sql .. ok
All tests successful.
Files=1, Tests=3,  0 wallclock secs ( 0.00 usr +  0.01 sys =  0.01 CPU)
Result: PASS

I can also run the entire test suite with no errors.

Expected behavior

I expect running a single test file to run just like it does when running the entire suite with npx supabase db test.

Screenshots

see test output inline above.

System information

  • OS: [e.g. macOS, Windows] macOS
  • Browser (if applies) [e.g. chrome, safari] n/a
  • Version of supabase-js: [e.g. 6.0.2] n/a
  • Version of Node.js: [e.g. 10.10.0] v24.13.0

supabase CLI version 2.76.3

Additional context

The single-test run case worked fine until about the time the CLI was changed to print the full path to the test files in the output. My guess is that something is chrooting the working directory in the single-test variant. Since it is now using the full path instead of relative path, it cannot find the file even though it exists.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions