Skip to content

CI - cargo test runs C# and TypeScript tests#4921

Open
bfops wants to merge 58 commits intobfops/translate-scriptfrom
bfops/cargo-test-all
Open

CI - cargo test runs C# and TypeScript tests#4921
bfops wants to merge 58 commits intobfops/translate-scriptfrom
bfops/cargo-test-all

Conversation

@bfops
Copy link
Copy Markdown
Collaborator

@bfops bfops commented Apr 30, 2026

Description of Changes

C# and TypeScript tests can now be run via cargo test.

This also involved updating some test code to take a server url override, so they could use the existing SpacetimeDBGuard (which starts the server on an arbitrary port rather than a hardcoded 3000).

API and ABI breaking changes

None. CI only.

Expected complexity level and risk

2

Testing

Failure reporting was checked with synthetic failing tests after the standard harness checks.

TypeScript harness:

  • Run the wrapped TypeScript suite with cargo test -p spacetimedb-typescript-tests
  • This runs pnpm build, pnpm vitest run with a JUnit report, then pnpm vitest typecheck --run. Reports are written under target/language-tests/typescript/.

C# harness:

  • Pre-build the local server binaries before running the full C# harness:
    • cargo build -p spacetimedb-cli -p spacetimedb-standalone --features spacetimedb-standalone/allow_loopback_http_for_tests
  • Run the wrapped C# suite with cargo test -p spacetimedb-csharp-tests
  • This runs the bindings tests, packs/restores the SDK solution against local NuGet packages, runs the SDK tests, and then runs the C# regression script against a temporary SpacetimeDB server started through spacetimedb-guard. TRX reports are written under target/language-tests/csharp/.

Synthetic failure check

  • Added a temporary failing Vitest test and ran:
    • cargo test -p spacetimedb-typescript-tests --test typescript -- --filter SyntheticHarnessFailure
  • Verified the command exited with status 1 and reported the failure like this:
FAIL  tests/synthetic_harness_failure.test.ts > SyntheticHarnessFailure reports TypeScript assertion failures
AssertionError: expected 'actual TypeScript failure' to be 'expected TypeScript success'

Expected: "expected TypeScript success"
Received: "actual TypeScript failure"

command failed in .../crates/bindings-typescript:
  pnpm test -- --reporter=default --reporter=junit --outputFile=... -t SyntheticHarnessFailure
status: exit status: 1
  • Added a temporary failing xUnit test and ran:
    • cargo test -p spacetimedb-csharp-tests --test csharp -- --filter SyntheticHarnessFailure
  • Verified the command exited with status 1 and reported the failure like this:
SyntheticHarnessFailureTests.SyntheticHarnessFailureReportsCsharpAssertionFailures [FAIL]
Error Message:
 Assert.Equal() Failure: Strings differ
Expected: "expected C# success"
Actual:   "actual C# failure"

command failed in .../sdks/csharp:
  dotnet test -warnaserror --results-directory ... --logger trx;LogFileName=sdk.trx --no-restore --filter SyntheticHarnessFailure
status: exit status: 1

@bfops bfops linked an issue Apr 30, 2026 that may be closed by this pull request
2 tasks
Comment thread tools/ci/src/main.rs Outdated
bfops and others added 4 commits April 30, 2026 15:07
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
….com:clockworklabs/SpacetimeDB into bfops/cargo-test-all
Comment thread tools/run-all-tests.sh Outdated
bfops and others added 3 commits May 1, 2026 10:16
@bfops bfops changed the base branch from master to bfops/flexible-csharp May 1, 2026 18:20
@bfops bfops changed the base branch from bfops/flexible-csharp to master May 1, 2026 19:59
@bfops bfops changed the base branch from master to bfops/flexible-csharp May 1, 2026 20:04
Comment thread crates/language-test-support/src/lib.rs Outdated
Comment thread crates/typescript-tests/tests/typescript.rs Outdated
Comment thread crates/typescript-tests/tests/typescript.rs Outdated
Comment thread crates/language-test-support/src/lib.rs Outdated
Comment thread crates/language-test-support/src/lib.rs Outdated
Comment thread crates/language-test-support/src/lib.rs Outdated
@bfops bfops changed the base branch from master to bfops/argument-null-exception May 5, 2026 17:58
@bfops bfops mentioned this pull request May 5, 2026
6 tasks
@bfops bfops changed the base branch from bfops/argument-null-exception to master May 5, 2026 23:41
@jdetter
Copy link
Copy Markdown
Collaborator

jdetter commented May 6, 2026

Very unlikely to be related to this PR but the typescript tests don't pass on Windows:

src/sdk/logger.ts:1:42 - error TS2307: Cannot find module 'safe-stable-stringify' or its corresponding type declarations.

1 import { stringify as ssStringify } from 'safe-stable-stringify';
                                           ~~~~~~~~~~~~~~~~~~~~~~~

src/sdk/logger.ts:76:23 - error TS7006: Parameter 'key' implicitly has an 'any' type.

76   ssStringify(value, (key, current) => {
                         ~~~

src/sdk/logger.ts:76:28 - error TS7006: Parameter 'current' implicitly has an 'any' type.

76   ssStringify(value, (key, current) => {
                              ~~~~~~~


Found 3 errors in the same file, starting at: src/sdk/logger.ts:1

 ELIFECYCLE  Command failed with exit code 1.
command failed in C:\Users\boppy\clockwork\SpacetimeDB\crates/bindings-typescript:
  pnpm build
status: exit code: 1
error: test failed, to rerun pass `-p spacetimedb-typescript-tests --test typescript`

Caused by:
  process didn't exit successfully: `C:\Users\boppy\clockwork\SpacetimeDB\target\debug\deps\typescript-f5bc0a56063fb3d6.exe` (exit code: 1)

@jdetter
Copy link
Copy Markdown
Collaborator

jdetter commented May 6, 2026

csharp tests don't work on windows due to executing a bash script:

Workload updates are available. Run `dotnet workload list` for more information.
: invalid option nameconfig.sh: line 1: set: pipefail
command failed in C:\Users\boppy\clockwork\SpacetimeDB\sdks/csharp:
  bash ./tools~/write-nuget-config.sh ../..
status: exit code: 2
error: test failed, to rerun pass `-p spacetimedb-csharp-tests --test csharp`

Caused by:
  process didn't exit successfully: `C:\Users\boppy\clockwork\SpacetimeDB\target\debug\deps\csharp-2603e4bb2c95094a.exe` (exit code: 1)

Copy link
Copy Markdown
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

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

I think ideally this would work on both Unix and Windows based systems. There seem to be a few problems preventing this from working on Windows and I think that should maybe be a requirement for this PR. What do you think?

Comment thread crates/csharp-tests/tests/csharp.rs Outdated
// if they're not pushed to NuGet.
// See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file.
let status = Command::new("bash")
.args(["./tools~/write-nuget-config.sh", "../.."])
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.

In order for this to work on Windows as well it might be best to translate this script into rust and then inline it here, what do you think? Either that or we need an equivalent powershell script so that this will also work on windows and we need to invoke the powershell script instead if we're running on windows.

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.

Yeah, that's fair.

I've created #4970 to do this more generally for all of our bash scripts.

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.

translating these ones in #4971

Comment thread crates/csharp-tests/tests/csharp.rs Outdated
let guard = SpacetimeDbGuard::spawn_in_temp_data_dir();
let cwd = workspace.join("sdks/csharp");
let status = Command::new("bash")
.args(["tools~/run-regression-tests.sh"])
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.

same here - what do you think about translating this script into rust and inlining it here?

@bfops
Copy link
Copy Markdown
Collaborator Author

bfops commented May 6, 2026

Very unlikely to be related to this PR but the typescript tests don't pass on Windows:

@jdetter Interesting. Created #4969 to track.

@bfops bfops mentioned this pull request May 6, 2026
2 tasks
@bfops bfops changed the base branch from master to bfops/translate-script May 6, 2026 19:14
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.

Run simple language tests under cargo test

2 participants