refactor(natu): rename xatu
This commit was merged in pull request #97.
This commit is contained in:
@@ -24,7 +24,7 @@ in
|
||||
configs/nixos/hosts/neogaia/hardware-configuration.nix \
|
||||
configs/nixos/hosts/pikachu/hardware-configuration.nix \
|
||||
configs/nixos/hosts/zeus/hardware-configuration.nix \
|
||||
src/xatu/testdata \
|
||||
src/natu/testdata \
|
||||
third_party \
|
||||
-- .
|
||||
treefmt
|
||||
|
||||
@@ -6,7 +6,7 @@ inputs.treefmt-nix.lib.evalModule inputs.nixpkgs.legacyPackages.${system} {
|
||||
|
||||
settings.formatter.nixfmt.excludes = [
|
||||
"configs/nixos/hosts/*/hardware-configuration.nix"
|
||||
"src/xatu/testdata/*.nix"
|
||||
"src/natu/testdata/*.nix"
|
||||
"third_party/**"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
|
||||
|
||||
rust_library(
|
||||
name = "xatu_lib",
|
||||
crate_name = "xatu",
|
||||
name = "natu_lib",
|
||||
crate_name = "natu",
|
||||
srcs = [
|
||||
"ast.rs",
|
||||
"file_store.rs",
|
||||
"natu.rs",
|
||||
"parser.rs",
|
||||
"rules.rs",
|
||||
"rules/let_order.rs",
|
||||
@@ -13,7 +14,6 @@ rust_library(
|
||||
"rules/manual_inherit_from.rs",
|
||||
"rules/unquoted_uri.rs",
|
||||
"scope_graph.rs",
|
||||
"xatu.rs",
|
||||
],
|
||||
deps = [
|
||||
"//src/status:status",
|
||||
@@ -25,30 +25,30 @@ rust_library(
|
||||
rust_test(
|
||||
name = "file_store_test",
|
||||
srcs = ["file_store_test.rs"],
|
||||
deps = [":xatu_lib"],
|
||||
deps = [":natu_lib"],
|
||||
)
|
||||
|
||||
rust_test(
|
||||
name = "xatu_test",
|
||||
srcs = ["xatu_test.rs"],
|
||||
name = "natu_test",
|
||||
srcs = ["natu_test.rs"],
|
||||
data = [
|
||||
"testdata/clean.nix",
|
||||
"testdata/invalid.nix",
|
||||
"testdata/lint_findings.nix",
|
||||
],
|
||||
deps = [
|
||||
":xatu_lib",
|
||||
":natu_lib",
|
||||
"//src/status:status",
|
||||
"//third_party/crates:googletest",
|
||||
],
|
||||
)
|
||||
|
||||
rust_binary(
|
||||
name = "xatu",
|
||||
crate_name = "xatu_cli",
|
||||
srcs = ["xatu_main.rs"],
|
||||
name = "natu",
|
||||
crate_name = "natu_cli",
|
||||
srcs = ["natu_main.rs"],
|
||||
deps = [
|
||||
":xatu_lib",
|
||||
":natu_lib",
|
||||
"//src/monorepo:monorepo",
|
||||
"//src/status:status",
|
||||
"//third_party/crates:clap",
|
||||
@@ -1,14 +1,14 @@
|
||||
[package]
|
||||
name = "xatu"
|
||||
name = "natu"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
path = "xatu.rs"
|
||||
path = "natu.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "xatu"
|
||||
path = "xatu_main.rs"
|
||||
name = "natu"
|
||||
path = "natu_main.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use xatu::{FileStore, SourceFile};
|
||||
use natu::{FileStore, SourceFile};
|
||||
|
||||
fn source_file(path: &str, source: &str) -> SourceFile {
|
||||
SourceFile {
|
||||
@@ -53,7 +53,7 @@ fn line_range(source: &str, range: ast::SourceRange) -> (usize, usize) {
|
||||
(start, end)
|
||||
}
|
||||
|
||||
/// Analyzes source files and returns the diagnostics Xatu finds.
|
||||
/// Analyzes source files and returns the diagnostics Natu finds.
|
||||
pub fn future_sight(files: Vec<SourceFile>) -> status::Result<Report> {
|
||||
let mut store = FileStore::default();
|
||||
let mut diagnostics = Vec::new();
|
||||
@@ -1,8 +1,8 @@
|
||||
use clap::Parser;
|
||||
use natu::{Report, SourceFile};
|
||||
use status::ResultExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::ExitCode;
|
||||
use xatu::{Report, SourceFile};
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let args = Args::parse();
|
||||
@@ -44,7 +44,7 @@ fn analyze(args: Args) -> status::Result<Report> {
|
||||
.flatten()
|
||||
.collect();
|
||||
|
||||
xatu::future_sight(files)
|
||||
natu::future_sight(files)
|
||||
}
|
||||
|
||||
fn collect_source_files(path: &Path) -> status::Result<Vec<SourceFile>> {
|
||||
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
||||
use googletest::matchers::{contains, eq, is_true};
|
||||
use googletest::{OrFail, expect_that, gtest};
|
||||
use status::Code;
|
||||
use xatu::SourceFile;
|
||||
use natu::SourceFile;
|
||||
|
||||
fn fixture_source(path: &str) -> googletest::Result<SourceFile> {
|
||||
Ok(SourceFile {
|
||||
@@ -20,20 +20,20 @@ fn fixture_path(path: &str) -> googletest::Result<PathBuf> {
|
||||
let runfiles = PathBuf::from(std::env::var("TEST_SRCDIR").or_fail()?);
|
||||
let workspace = std::env::var("TEST_WORKSPACE").or_fail()?;
|
||||
|
||||
Ok(runfiles.join(workspace).join("src/xatu").join(path))
|
||||
Ok(runfiles.join(workspace).join("src/natu").join(path))
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_accepts_clean_source() -> googletest::Result<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/clean.nix")?]).or_fail()?;
|
||||
fn natu_accepts_clean_source() -> googletest::Result<()> {
|
||||
let report = natu::future_sight(vec![fixture_source("testdata/clean.nix")?]).or_fail()?;
|
||||
|
||||
expect_that!(report.is_clean(), is_true());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_rejects_invalid_source() -> googletest::Result<()> {
|
||||
let error = xatu::future_sight(vec![fixture_source("testdata/invalid.nix")?])
|
||||
fn natu_rejects_invalid_source() -> googletest::Result<()> {
|
||||
let error = natu::future_sight(vec![fixture_source("testdata/invalid.nix")?])
|
||||
.err()
|
||||
.or_fail()?;
|
||||
|
||||
@@ -42,8 +42,8 @@ fn xatu_rejects_invalid_source() -> googletest::Result<()> {
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
fn natu_reports_out_of_order_let_bindings() -> googletest::Result<()> {
|
||||
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
|
||||
let let_order_count = report
|
||||
.diagnostics
|
||||
@@ -55,8 +55,8 @@ fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> {
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_unquoted_uri() -> googletest::Result<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
fn natu_reports_unquoted_uri() -> googletest::Result<()> {
|
||||
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
|
||||
let findings = report
|
||||
.diagnostics
|
||||
@@ -79,8 +79,8 @@ fn xatu_reports_unquoted_uri() -> googletest::Result<()> {
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_manual_inherit() -> googletest::Result<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
fn natu_reports_manual_inherit() -> googletest::Result<()> {
|
||||
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
|
||||
let manual_inherit_count = report
|
||||
.diagnostics
|
||||
@@ -92,8 +92,8 @@ fn xatu_reports_manual_inherit() -> googletest::Result<()> {
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_manual_inherit_from() -> googletest::Result<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
fn natu_reports_manual_inherit_from() -> googletest::Result<()> {
|
||||
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
|
||||
let manual_inherit_from_count = report
|
||||
.diagnostics
|
||||
Reference in New Issue
Block a user