Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: split integration tests from CLI (part 1) #22308

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

mmastrac
Copy link
Contributor

@mmastrac mmastrac commented Feb 6, 2024

This PR separates integration tests from CLI tests into a new project named cli_tests. This is a prerequisite for an integration test runner that can work with either the CLI binary in the current project, or one that is built ahead of time.

Background

Rust does not have the concept of artifact dependencies yet (rust-lang/cargo#9096). Because of this, the only way we can ensure a binary is built before running associated tests is by hanging tests off the crate with the binary itself.

Unfortunately this means that to run those tests, you must build the binary and in the case of the deno executable that might be a 10 minute wait in release mode.

Implementation

To allow for tests to run with and without the requirement that the binary is up-to-date, we split the integration tests into a project of their own. As these tests would not require the binary to build itself before being run as-is, we add a stub integration [[test]] target in the cli project that invokes these tests using cargo test.

The stub test runner we add has harness = false so that we can get access to a main function. This main function's sole job is to execvp the command cargo test -p deno_cli, effectively "calling" another cargo target.

This ensures that the deno executable is always correctly rebuilt before running the stub test runner from cli, and gets us closer to be able to run the entire integration test suite on arbitrary deno executables (and therefore split the build into multiple phases).

The new cli_tests project lives within cli to avoid a large PR. In later PRs, the test data will be split from the cli project. As there are a few thousand files, it'll be better to do this as a completely separate PR to avoid noise.

@mmastrac mmastrac closed this Feb 7, 2024
@mmastrac mmastrac reopened this Feb 8, 2024
@mmastrac mmastrac closed this Feb 8, 2024
@mmastrac mmastrac reopened this Feb 8, 2024
@mmastrac mmastrac changed the title refactor: move most integration tests to tests/ refactor: split integration tests from CLI (part 1) Feb 8, 2024
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

Great!

@mmastrac mmastrac merged commit dcbbcd2 into denoland:main Feb 9, 2024
17 checks passed
littledivy pushed a commit that referenced this pull request Feb 15, 2024
This PR separates integration tests from CLI tests into a new project
named `cli_tests`. This is a prerequisite for an integration test runner
that can work with either the CLI binary in the current project, or one
that is built ahead of time.

## Background

Rust does not have the concept of artifact dependencies yet
(rust-lang/cargo#9096). Because of this, the
only way we can ensure a binary is built before running associated tests
is by hanging tests off the crate with the binary itself.

Unfortunately this means that to run those tests, you _must_ build the
binary and in the case of the deno executable that might be a 10 minute
wait in release mode.

## Implementation

To allow for tests to run with and without the requirement that the
binary is up-to-date, we split the integration tests into a project of
their own. As these tests would not require the binary to build itself
before being run as-is, we add a stub integration `[[test]]` target in
the `cli` project that invokes these tests using `cargo test`.

The stub test runner we add has `harness = false` so that we can get
access to a `main` function. This `main` function's sole job is to
`execvp` the command `cargo test -p deno_cli`, effectively "calling"
another cargo target.

This ensures that the deno executable is always correctly rebuilt before
running the stub test runner from `cli`, and gets us closer to be able
to run the entire integration test suite on arbitrary deno executables
(and therefore split the build into multiple phases).

The new `cli_tests` project lives within `cli` to avoid a large PR. In
later PRs, the test data will be split from the `cli` project. As there
are a few thousand files, it'll be better to do this as a completely
separate PR to avoid noise.
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