Skip to content

Commit aae33db

Browse files
author
Paolo Tranquilli
committed
Rust: add basic integration tests
This adds testing of well-formed rust projects and workspaces, using both `Cargo.toml` and `rust-project.json` manifests.
1 parent afb9ffa commit aae33db

27 files changed

+124
-4
lines changed

rust/integration-tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
import shutil
3+
4+
class _Manifests:
5+
def __init__(self, cwd):
6+
self.dir = cwd / "manifests"
7+
8+
def select(self, name: str):
9+
(self.dir / name).rename(name)
10+
shutil.rmtree(self.dir)
11+
12+
13+
@pytest.fixture
14+
def manifests(cwd):
15+
return _Manifests(cwd)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| src/main.rs:4:1:6:1 | main |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import rust
2+
3+
from Function f
4+
where exists(f.getLocation().getFile().getRelativePath())
5+
select f
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[workspace]
2+
[package]
3+
name = "hello-cargo"
4+
version = "0.1.0"
5+
edition = "2021"
6+
7+
[dependencies]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"crates": [{
3+
"root_module": "src/main.rs",
4+
"edition": "2021",
5+
"deps": []
6+
}]
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src/directory_module/mod.rs
2+
src/directory_module/nested_module.rs
3+
src/file_module.rs
4+
src/main.rs

rust/integration-tests/hello-project/src/directory_module/ignored.rs

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod nested_module;

rust/integration-tests/hello-project/src/directory_module/nested_module.rs

Whitespace-only changes.

rust/integration-tests/hello-project/src/file_module.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)