chore(release): prepare public source release
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "envdiff"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
readme.workspace = true
|
||||
publish.workspace = true
|
||||
description = "Capture and compare environment variable state for AI-friendly debugging."
|
||||
keywords.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
common = { path = "../common", default-features = false }
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
windowsupport = { path = "../windowsupport" }
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd.workspace = true
|
||||
predicates.workspace = true
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
//! Binary entry point for `envdiff`.
|
||||
#![allow(clippy::multiple_crate_versions)]
|
||||
|
||||
fn main() {
|
||||
std::process::exit(envdiff::main_entry());
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
//! Integration tests for the `envdiff` command.
|
||||
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
use assert_cmd::Command;
|
||||
use predicates::prelude::*;
|
||||
|
||||
fn cargo_command() -> Command {
|
||||
Command::cargo_bin("envdiff").expect("binary")
|
||||
}
|
||||
|
||||
struct TempTestDir {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
impl TempTestDir {
|
||||
fn path(&self) -> &std::path::Path {
|
||||
&self.path
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TempTestDir {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::remove_dir_all(&self.path);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runs_cmd_and_reports_environment_diff_as_json() {
|
||||
let temp = unique_temp_dir();
|
||||
let script = temp.path().join("mutate.cmd");
|
||||
fs::write(
|
||||
&script,
|
||||
"@echo off\r\nset TEST_FLAG=enabled\r\nset PATH=%PATH%;C:\\Mercury\\Bin\r\n",
|
||||
)
|
||||
.expect("script");
|
||||
|
||||
let mut command = cargo_command();
|
||||
command
|
||||
.arg("run")
|
||||
.arg("--json")
|
||||
.arg("--shell")
|
||||
.arg("cmd")
|
||||
.arg("--")
|
||||
.arg(&script)
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("\"added\""))
|
||||
.stdout(predicate::str::contains("\"name\":\"TEST_FLAG\""))
|
||||
.stdout(predicate::str::contains("\"path_like_changes\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_includes_envdiff_examples() {
|
||||
let mut command = cargo_command();
|
||||
command
|
||||
.arg("--help")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("snapshot"))
|
||||
.stdout(predicate::str::contains("run --shell cmd"))
|
||||
.stdout(predicate::str::contains("ConvertFrom-Json"));
|
||||
}
|
||||
|
||||
fn unique_temp_dir() -> TempTestDir {
|
||||
static NEXT_ID: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
loop {
|
||||
let unique = NEXT_ID.fetch_add(1, Ordering::Relaxed);
|
||||
let path =
|
||||
std::env::temp_dir().join(format!("envdiff-test-{}-{unique}", std::process::id()));
|
||||
match fs::create_dir(&path) {
|
||||
Ok(()) => return TempTestDir { path },
|
||||
Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => {}
|
||||
Err(error) => panic!("tempdir: {error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user