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

move tests to their packages directory #360

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generator/plugins/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def customizations(spec: model.LSPModel) -> model.LSPModel:
return spec


def generate_from_spec(spec: model.LSPModel, output_dir: str, test_dir: str) -> None:
def generate_from_spec(spec: model.LSPModel, output_dir: str, _test_dir: str) -> None:
spec = customizations(spec)
code = TypesCodeGenerator(spec).get_code()

Expand Down
2 changes: 1 addition & 1 deletion generator/plugins/rust/rust_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def generate_from_spec(spec: model.LSPModel, output_dir: str, test_dir: str) ->
(output_path / file_name).write_text(code[file_name], encoding="utf-8")

# update tests if exists
test_path = pathlib.Path(test_dir) / "src" / "main.rs"
test_path = pathlib.Path(output_dir) / "src" / "test.rs"
if test_path.exists():
generate_test_code(spec, test_path)

Expand Down
2 changes: 1 addition & 1 deletion packages/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Issues = "https://github.com/microsoft/lsprotocol/issues"
Source = "https://github.com/microsoft/lsprotocol"

[tool.flit.sdist]
include = ["lsprotocol/", "README.md", "LICENSE"]
include = ["lsprotocol/", "tests/", "README.md", "LICENSE"]
Copy link
Member

Choose a reason for hiding this comment

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

@T-256 Do you recommend including tests in the package? It will be incomplete as the generated test data, won't be part of it. It will get testing of special cases, if tests are run only with this package.

Copy link
Author

Choose a reason for hiding this comment

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

Do you recommend including tests in the package?

motivations here are same as other these python packages:
encode/httpx#2927
encode/httpcore#799

An usecase would be for package-indexing managers want to able test packages from sdist.

exclude = ["lsprotocol/__pycache__/", "requirements.in", "requirements.txt"]

[tool.mypy]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/rust/lsprotocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ keywords = ["lsp"]
proposed=[]

[dependencies]
glob = "0.3.1"
serde = {version ="1.0.152", features = ["derive"]}
serde_json = "1.0.93"
serde_repr = "0.1.10"
Expand Down
12 changes: 2 additions & 10 deletions tests/rust/src/main.rs → packages/rust/lsprotocol/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[cfg(test)]
mod tests {
use glob::glob;
use lsprotocol::*;
use super::*;
use serde::Deserialize;
use std::fs;

Expand Down Expand Up @@ -355,7 +355,7 @@ mod tests {
println!("Running generated data tests");
let cwd = std::env::current_dir()
.unwrap()
.join("../../packages/testdata");
.join("../../../../generator/plugins/testdata");
let env_value = std::env::var("LSP_TEST_DATA_PATH")
.unwrap_or_else(|_| cwd.to_str().unwrap().to_string());
println!("TEST_DATA_ROOT: {}", env_value);
Expand All @@ -364,11 +364,3 @@ mod tests {
}
}
}

fn main() {
// Use data from test error report here to debug
// let json_data = "";

// Update the type here to debug
// serde_json::from_str::<lsprotocol::TextDocumentCompletionRequest>(json_data).unwrap();
}
17 changes: 0 additions & 17 deletions tests/rust/Cargo.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading