Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
91
akode-rs/exec-server/src/local_file_system_read_tests.rs
Normal file
91
akode-rs/exec-server/src/local_file_system_read_tests.rs
Normal file
@@ -0,0 +1,91 @@
|
||||
//! Regression coverage for bounded, cancellable reads and regular-file validation.
|
||||
|
||||
#[cfg(unix)]
|
||||
use super::CancellableReader;
|
||||
use super::MAX_READ_FILE_BYTES;
|
||||
use crate::ReadFileOptions;
|
||||
use crate::local_file_system::LOCAL_FS;
|
||||
use akode_utils_path_uri::PathUri;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
use test_case::test_case;
|
||||
|
||||
#[test_case(true ; "follow")]
|
||||
#[test_case(false ; "no_follow")]
|
||||
#[tokio::test]
|
||||
async fn reads_file_larger_than_tokio_buffer(follow_symlinks: bool) -> anyhow::Result<()> {
|
||||
let directory = TempDir::new()?;
|
||||
let path = directory.path().canonicalize()?.join("large.bin");
|
||||
let contents = vec![0x5a; 4 * 1024 * 1024];
|
||||
std::fs::write(&path, &contents)?;
|
||||
assert_eq!(
|
||||
LOCAL_FS
|
||||
.read_file(
|
||||
&PathUri::from_host_native_path(&path)?,
|
||||
ReadFileOptions { follow_symlinks },
|
||||
/*sandbox*/ None,
|
||||
)
|
||||
.await?,
|
||||
contents,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(true ; "follow")]
|
||||
#[test_case(false ; "no_follow")]
|
||||
#[tokio::test]
|
||||
async fn rejects_oversized_file(follow_symlinks: bool) -> anyhow::Result<()> {
|
||||
let directory = TempDir::new()?;
|
||||
let path = directory.path().canonicalize()?.join("oversized.bin");
|
||||
std::fs::File::create(&path)?.set_len(MAX_READ_FILE_BYTES + 1)?;
|
||||
let error = LOCAL_FS
|
||||
.read_file(
|
||||
&PathUri::from_host_native_path(&path)?,
|
||||
ReadFileOptions { follow_symlinks },
|
||||
/*sandbox*/ None,
|
||||
)
|
||||
.await
|
||||
.expect_err("oversized file must be rejected before allocation");
|
||||
assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn cancellation_stops_a_reader_after_its_first_chunk() -> anyhow::Result<()> {
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
let (socket, mut writer) = UnixStream::pair()?;
|
||||
let cancelled = CancellationToken::new();
|
||||
let (reached_tx, reached_rx) = std::sync::mpsc::channel();
|
||||
let (resume_tx, resume_rx) = std::sync::mpsc::channel::<()>();
|
||||
let worker = std::thread::spawn({
|
||||
let cancelled = cancelled.clone();
|
||||
move || -> std::io::Result<()> {
|
||||
let mut reader = CancellableReader {
|
||||
reader: socket,
|
||||
cancelled,
|
||||
};
|
||||
let mut first = [0];
|
||||
reader.read_exact(&mut first)?;
|
||||
let _ = reached_tx.send(first);
|
||||
let _ = resume_rx.recv();
|
||||
reader.read_to_end(&mut Vec::new()).map(|_| ())
|
||||
}
|
||||
});
|
||||
writer.write_all(b"x")?;
|
||||
let first = reached_rx.recv()?;
|
||||
cancelled.cancel();
|
||||
// Closing the peer also makes a missing cancellation check fail without hanging the test.
|
||||
drop(writer);
|
||||
drop(resume_tx);
|
||||
let error = worker
|
||||
.join()
|
||||
.unwrap()
|
||||
.expect_err("cancelled read must stop");
|
||||
assert_eq!((first, error.kind()), (*b"x", std::io::ErrorKind::Other));
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user