mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 12:16:43 +00:00
Some checks are pending
CI / benchmarks-instrumented (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
115 lines
2.5 KiB
Rust
115 lines
2.5 KiB
Rust
use std::path::PathBuf;
|
|
|
|
#[cfg(feature = "instrumented")]
|
|
pub mod criterion;
|
|
pub mod real_world_projects;
|
|
|
|
pub static NUMPY_GLOBALS: TestFile = TestFile::new(
|
|
"numpy/globals.py",
|
|
include_str!("../resources/numpy/globals.py"),
|
|
);
|
|
|
|
pub static UNICODE_PYPINYIN: TestFile = TestFile::new(
|
|
"unicode/pypinyin.py",
|
|
include_str!("../resources/pypinyin.py"),
|
|
);
|
|
|
|
pub static PYDANTIC_TYPES: TestFile = TestFile::new(
|
|
"pydantic/types.py",
|
|
include_str!("../resources/pydantic/types.py"),
|
|
);
|
|
|
|
pub static NUMPY_CTYPESLIB: TestFile = TestFile::new(
|
|
"numpy/ctypeslib.py",
|
|
include_str!("../resources/numpy/ctypeslib.py"),
|
|
);
|
|
|
|
// "https://raw.githubusercontent.com/DHI/mikeio/b7d26418f4db2909b0aa965253dbe83194d7bb5b/tests/test_dataset.py"
|
|
pub static LARGE_DATASET: TestFile = TestFile::new(
|
|
"large/dataset.py",
|
|
include_str!("../resources/large/dataset.py"),
|
|
);
|
|
|
|
/// Relative size of a test case. Benchmarks can use it to configure the time for how long a benchmark should run to get stable results.
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
|
|
pub enum TestCaseSpeed {
|
|
/// A test case that is fast to run
|
|
Fast,
|
|
|
|
/// A normal test case
|
|
Normal,
|
|
|
|
/// A slow test case
|
|
Slow,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct TestCase {
|
|
file: TestFile,
|
|
speed: TestCaseSpeed,
|
|
}
|
|
|
|
impl TestCase {
|
|
pub const fn fast(file: TestFile) -> Self {
|
|
Self {
|
|
file,
|
|
speed: TestCaseSpeed::Fast,
|
|
}
|
|
}
|
|
|
|
pub const fn normal(file: TestFile) -> Self {
|
|
Self {
|
|
file,
|
|
speed: TestCaseSpeed::Normal,
|
|
}
|
|
}
|
|
|
|
pub const fn slow(file: TestFile) -> Self {
|
|
Self {
|
|
file,
|
|
speed: TestCaseSpeed::Slow,
|
|
}
|
|
}
|
|
|
|
pub fn code(&self) -> &str {
|
|
self.file.code
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
self.file.name
|
|
}
|
|
|
|
pub fn speed(&self) -> TestCaseSpeed {
|
|
self.speed
|
|
}
|
|
|
|
pub fn path(&self) -> PathBuf {
|
|
PathBuf::from(file!())
|
|
.parent()
|
|
.unwrap()
|
|
.parent()
|
|
.unwrap()
|
|
.join("resources")
|
|
.join(self.name())
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct TestFile {
|
|
name: &'static str,
|
|
code: &'static str,
|
|
}
|
|
|
|
impl TestFile {
|
|
pub const fn new(name: &'static str, code: &'static str) -> Self {
|
|
Self { name, code }
|
|
}
|
|
|
|
pub fn code(&self) -> &str {
|
|
self.code
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
self.name
|
|
}
|
|
}
|