앱의 7z 형식 변환과 프로토콜 왕복 시험을 추가함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
2e4064699aaad8cbbd44bb0420012cdfaf323d36
변경된 파일 19개
+1,804-33| @@ -3948,6 +3948,14 @@ dependencies = [ | ||
| 3948 | 3948 | "zipelo-rust-memory-zip-create", |
| 3949 | 3949 | ] |
| 3950 | 3950 | |
| 3951 | 추가: [[package]] | |
| 3952 | 추가: name = "zipelo-archive-worker" | |
| 3953 | 추가: version = "0.1.0" | |
| 3954 | 추가: dependencies = [ | |
| 3955 | 추가: "sha2", | |
| 3956 | 추가: "zlib-rs", | |
| 3957 | 추가: ] | |
| 3958 | 추가: | |
| 3951 | 3959 | [[package]] |
| 3952 | 3960 | name = "zipelo-memory-gzip-reader" |
| 3953 | 3961 | version = "0.1.0" |
| @@ -3976,6 +3984,7 @@ version = "0.1.0" | ||
| 3976 | 3984 | dependencies = [ |
| 3977 | 3985 | "eframe", |
| 3978 | 3986 | "zipelo-app-core-memory", |
| 3987 | 추가: "zipelo-archive-worker", | |
| 3979 | 3988 | ] |
| 3980 | 3989 | |
| 3981 | 3990 | [[package]] |
| @@ -18,6 +18,7 @@ ui = ["dep:eframe"] | ||
| 18 | 18 | ui-fixture = ["ui"] |
| 19 | 19 | |
| 20 | 20 | [dependencies] |
| 21 | 추가: worker_protocol = { package = "zipelo-archive-worker", path = "../rust-archive-worker" } | |
| 21 | 22 | core_memory = { package = "zipelo-app-core-memory", path = "../rust-app-core-memory" } |
| 22 | 23 | eframe = { version = "=0.37.0", optional = true, default-features = false, features = ["accesskit", "clipboard", "glow", "system_fonts", "wayland", "x11"] } |
| 23 | 24 | |
| @@ -33,3 +34,11 @@ path = "../../tests/rust-ui-memory-app/regressions.rs" | ||
| 33 | 34 | [[test]] |
| 34 | 35 | name = "archive_ui" |
| 35 | 36 | path = "../../tests/rust-app-ui/regressions.rs" |
| 37 | 추가: | |
| 38 | 추가: [[test]] | |
| 39 | 추가: name = "real_worker" | |
| 40 | 추가: path = "../../tests/rust-app-real-worker/flows.rs" | |
| 41 | 추가: | |
| 42 | 추가: [[test]] | |
| 43 | 추가: name = "format_contract" | |
| 44 | 추가: path = "../../tests/rust-app-real-worker/formats.rs" |
| @@ -0,0 +1,677 @@ | ||
| 1 | 추가: use crate::archive_ui as ui; | |
| 2 | 추가: use std::{ | |
| 3 | 추가: cell::RefCell, | |
| 4 | 추가: io::{self, Read, Write}, | |
| 5 | 추가: path::PathBuf, | |
| 6 | 추가: process::{Command, Stdio}, | |
| 7 | 추가: rc::Rc, | |
| 8 | 추가: sync::{ | |
| 9 | 추가: Arc, Mutex, | |
| 10 | 추가: atomic::{AtomicBool, Ordering}, | |
| 11 | 추가: mpsc::{self, Receiver, SyncSender}, | |
| 12 | 추가: }, | |
| 13 | 추가: thread::{self, JoinHandle}, | |
| 14 | 추가: time::{Duration, Instant}, | |
| 15 | 추가: }; | |
| 16 | 추가: use worker_protocol::{protocol as wire, wire as codec}; | |
| 17 | 추가: | |
| 18 | 추가: macro_rules! convert_enum { | |
| 19 | 추가: ($name:ident, $from:ty, $to:ty, $($variant:ident),+) => { | |
| 20 | 추가: fn $name(value: $from) -> $to { | |
| 21 | 추가: match value { $(<$from>::$variant => <$to>::$variant),+ } | |
| 22 | 추가: } | |
| 23 | 추가: }; | |
| 24 | 추가: } | |
| 25 | 추가: convert_enum!( | |
| 26 | 추가: format_to_wire, | |
| 27 | 추가: ui::Format, | |
| 28 | 추가: wire::Format, | |
| 29 | 추가: Zip, | |
| 30 | 추가: Tar, | |
| 31 | 추가: Gzip, | |
| 32 | 추가: TarGzip, | |
| 33 | 추가: SevenZip | |
| 34 | 추가: ); | |
| 35 | 추가: convert_enum!( | |
| 36 | 추가: format_to_ui, | |
| 37 | 추가: wire::Format, | |
| 38 | 추가: ui::Format, | |
| 39 | 추가: Zip, | |
| 40 | 추가: Tar, | |
| 41 | 추가: Gzip, | |
| 42 | 추가: TarGzip, | |
| 43 | 추가: SevenZip | |
| 44 | 추가: ); | |
| 45 | 추가: convert_enum!( | |
| 46 | 추가: kind_to_ui, | |
| 47 | 추가: wire::EntryKind, | |
| 48 | 추가: ui::Kind, | |
| 49 | 추가: File, | |
| 50 | 추가: Directory, | |
| 51 | 추가: Link, | |
| 52 | 추가: Other | |
| 53 | 추가: ); | |
| 54 | 추가: convert_enum!( | |
| 55 | 추가: stage_to_ui, | |
| 56 | 추가: wire::Stage, | |
| 57 | 추가: ui::Stage, | |
| 58 | 추가: Scan, | |
| 59 | 추가: Read, | |
| 60 | 추가: Decode, | |
| 61 | 추가: Write, | |
| 62 | 추가: Verify, | |
| 63 | 추가: Commit | |
| 64 | 추가: ); | |
| 65 | 추가: convert_enum!( | |
| 66 | 추가: disposition_to_ui, | |
| 67 | 추가: wire::Disposition, | |
| 68 | 추가: ui::Disposition, | |
| 69 | 추가: Created, | |
| 70 | 추가: PartialRetained, | |
| 71 | 추가: Removed, | |
| 72 | 추가: CommitUncertain | |
| 73 | 추가: ); | |
| 74 | 추가: convert_enum!( | |
| 75 | 추가: outcome_to_ui, | |
| 76 | 추가: wire::Outcome, | |
| 77 | 추가: ui::Outcome, | |
| 78 | 추가: Completed, | |
| 79 | 추가: Failed, | |
| 80 | 추가: Cancelled | |
| 81 | 추가: ); | |
| 82 | 추가: convert_enum!( | |
| 83 | 추가: publication_to_ui, | |
| 84 | 추가: wire::Publication, | |
| 85 | 추가: ui::Publication, | |
| 86 | 추가: None, | |
| 87 | 추가: Partial, | |
| 88 | 추가: Complete, | |
| 89 | 추가: Uncertain | |
| 90 | 추가: ); | |
| 91 | 추가: convert_enum!( | |
| 92 | 추가: durability_to_ui, | |
| 93 | 추가: wire::Durability, | |
| 94 | 추가: ui::Durability, | |
| 95 | 추가: NotApplicable, | |
| 96 | 추가: Synced, | |
| 97 | 추가: Unconfirmed, | |
| 98 | 추가: Failed | |
| 99 | 추가: ); | |
| 100 | 추가: convert_enum!( | |
| 101 | 추가: cleanup_to_ui, | |
| 102 | 추가: wire::Cleanup, | |
| 103 | 추가: ui::Cleanup, | |
| 104 | 추가: Complete, | |
| 105 | 추가: Failed, | |
| 106 | 추가: Unconfirmed | |
| 107 | 추가: ); | |
| 108 | 추가: convert_enum!( | |
| 109 | 추가: cancel_to_ui, | |
| 110 | 추가: wire::CancelStatus, | |
| 111 | 추가: ui::CancelStatus, | |
| 112 | 추가: Requested, | |
| 113 | 추가: AlreadyRequested, | |
| 114 | 추가: TooLate, | |
| 115 | 추가: Finished | |
| 116 | 추가: ); | |
| 117 | 추가: fn list_to_wire(id: ui::ListId) -> wire::ListId { | |
| 118 | 추가: wire::ListId { | |
| 119 | 추가: catalog_version: id.catalog_version, | |
| 120 | 추가: format: format_to_wire(id.format), | |
| 121 | 추가: source_object: match id.source_object { | |
| 122 | 추가: ui::SourceObject::Unix { device, inode } => wire::SourceObject::Unix { device, inode }, | |
| 123 | 추가: ui::SourceObject::Windows { volume, file_id } => wire::SourceObject::Windows { | |
| 124 | 추가: volume_serial: volume, | |
| 125 | 추가: file_id, | |
| 126 | 추가: }, | |
| 127 | 추가: }, | |
| 128 | 추가: archive_bytes: id.archive_bytes, | |
| 129 | 추가: archive_sha256: id.archive_sha256, | |
| 130 | 추가: } | |
| 131 | 추가: } | |
| 132 | 추가: fn list_to_ui(id: wire::ListId) -> ui::ListId { | |
| 133 | 추가: ui::ListId { | |
| 134 | 추가: catalog_version: id.catalog_version, | |
| 135 | 추가: format: format_to_ui(id.format), | |
| 136 | 추가: source_object: match id.source_object { | |
| 137 | 추가: wire::SourceObject::Unix { device, inode } => ui::SourceObject::Unix { device, inode }, | |
| 138 | 추가: wire::SourceObject::Windows { | |
| 139 | 추가: volume_serial, | |
| 140 | 추가: file_id, | |
| 141 | 추가: } => ui::SourceObject::Windows { | |
| 142 | 추가: volume: volume_serial, | |
| 143 | 추가: file_id, | |
| 144 | 추가: }, | |
| 145 | 추가: }, | |
| 146 | 추가: archive_bytes: id.archive_bytes, | |
| 147 | 추가: archive_sha256: id.archive_sha256, | |
| 148 | 추가: } | |
| 149 | 추가: } | |
| 150 | 추가: fn start_to_wire(start: ui::Start) -> wire::Start { | |
| 151 | 추가: let action = match start { | |
| 152 | 추가: ui::Start::List { archive } => wire::Action::List { | |
| 153 | 추가: archive: wire::NativePath::from_path(&archive), | |
| 154 | 추가: }, | |
| 155 | 추가: ui::Start::Extract { | |
| 156 | 추가: archive, | |
| 157 | 추가: destination, | |
| 158 | 추가: selection, | |
| 159 | 추가: list_id, | |
| 160 | 추가: gzip_output_name, | |
| 161 | 추가: } => wire::Action::Extract { | |
| 162 | 추가: archive: wire::NativePath::from_path(&archive), | |
| 163 | 추가: destination: wire::NativePath::from_path(&destination), | |
| 164 | 추가: selection: match selection { | |
| 165 | 추가: ui::Selection::All => wire::Selection::All, | |
| 166 | 추가: ui::Selection::EntryIds(ids) => wire::Selection::EntryIds(ids), | |
| 167 | 추가: }, | |
| 168 | 추가: list_id: Some(list_to_wire(list_id)), | |
| 169 | 추가: gzip_output_name, | |
| 170 | 추가: }, | |
| 171 | 추가: ui::Start::CreateZip { | |
| 172 | 추가: sources, | |
| 173 | 추가: output_file, | |
| 174 | 추가: method, | |
| 175 | 추가: aes256, | |
| 176 | 추가: } => wire::Action::CreateZip { | |
| 177 | 추가: sources: sources | |
| 178 | 추가: .into_iter() | |
| 179 | 추가: .map(|(path, archive_name)| wire::Source { | |
| 180 | 추가: path: wire::NativePath::from_path(&path), | |
| 181 | 추가: archive_name, | |
| 182 | 추가: }) | |
| 183 | 추가: .collect(), | |
| 184 | 추가: output_file: wire::NativePath::from_path(&output_file), | |
| 185 | 추가: method: match method { | |
| 186 | 추가: ui::Method::Store => wire::Method::Store, | |
| 187 | 추가: ui::Method::Deflate => wire::Method::Deflate, | |
| 188 | 추가: }, | |
| 189 | 추가: encryption: if aes256 { | |
| 190 | 추가: wire::Encryption::Aes256 | |
| 191 | 추가: } else { | |
| 192 | 추가: wire::Encryption::None | |
| 193 | 추가: }, | |
| 194 | 추가: }, | |
| 195 | 추가: }; | |
| 196 | 추가: wire::Start { | |
| 197 | 추가: action, | |
| 198 | 추가: limits: wire::Limits::default(), | |
| 199 | 추가: } | |
| 200 | 추가: } | |
| 201 | 추가: fn error_to_ui(error: wire::ErrorCode) -> Option<ui::ErrorCode> { | |
| 202 | 추가: Some(match error { | |
| 203 | 추가: wire::ErrorCode::None => return None, | |
| 204 | 추가: wire::ErrorCode::Integrity => ui::ErrorCode::Integrity, | |
| 205 | 추가: wire::ErrorCode::UnsupportedFormat => ui::ErrorCode::UnsupportedFormat, | |
| 206 | 추가: wire::ErrorCode::UnsupportedFeature => ui::ErrorCode::UnsupportedFeature, | |
| 207 | 추가: wire::ErrorCode::WrongPassword => ui::ErrorCode::WrongPassword, | |
| 208 | 추가: wire::ErrorCode::UnsafePath => ui::ErrorCode::UnsafePath, | |
| 209 | 추가: wire::ErrorCode::Conflict => ui::ErrorCode::Conflict, | |
| 210 | 추가: wire::ErrorCode::Limit => ui::ErrorCode::Limit, | |
| 211 | 추가: wire::ErrorCode::Io => ui::ErrorCode::Io, | |
| 212 | 추가: wire::ErrorCode::Protocol => ui::ErrorCode::Protocol, | |
| 213 | 추가: wire::ErrorCode::Internal => ui::ErrorCode::Internal, | |
| 214 | 추가: wire::ErrorCode::SourceChanged => ui::ErrorCode::SourceChanged, | |
| 215 | 추가: wire::ErrorCode::InvalidRequest => ui::ErrorCode::InvalidRequest, | |
| 216 | 추가: }) | |
| 217 | 추가: } | |
| 218 | 추가: fn event_to_ui( | |
| 219 | 추가: message: wire::Message, | |
| 220 | 추가: expected: Option<wire::ActionKind>, | |
| 221 | 추가: ) -> Result<ui::Event, ()> { | |
| 222 | 추가: Ok(match message { | |
| 223 | 추가: wire::Message::Accepted { action, encryption } if expected == Some(action) => { | |
| 224 | 추가: ui::Event::Accepted { encryption } | |
| 225 | 추가: } | |
| 226 | 추가: wire::Message::Entry(entry) => ui::Event::Entry(ui::Entry { | |
| 227 | 추가: id: entry.entry_id, | |
| 228 | 추가: name: entry.name, | |
| 229 | 추가: kind: kind_to_ui(entry.kind), | |
| 230 | 추가: bytes: Some(entry.size), | |
| 231 | 추가: packed: Some(entry.compressed_size), | |
| 232 | 추가: encrypted: entry.encrypted, | |
| 233 | 추가: }), | |
| 234 | 추가: wire::Message::ListEnd { | |
| 235 | 추가: entry_count, | |
| 236 | 추가: list_id, | |
| 237 | 추가: } => ui::Event::ListEnd { | |
| 238 | 추가: entry_count, | |
| 239 | 추가: list_id: list_to_ui(list_id), | |
| 240 | 추가: }, | |
| 241 | 추가: wire::Message::PasswordRequired { | |
| 242 | 추가: challenge_id, | |
| 243 | 추가: attempt, | |
| 244 | 추가: purpose, | |
| 245 | 추가: } => ui::Event::PasswordRequired { | |
| 246 | 추가: challenge_id, | |
| 247 | 추가: attempt, | |
| 248 | 추가: encrypt: purpose == wire::PasswordPurpose::Encrypt, | |
| 249 | 추가: }, | |
| 250 | 추가: wire::Message::Progress { | |
| 251 | 추가: stage, | |
| 252 | 추가: processed_bytes, | |
| 253 | 추가: total_bytes, | |
| 254 | 추가: completed_entries, | |
| 255 | 추가: } => ui::Event::Progress { | |
| 256 | 추가: stage: stage_to_ui(stage), | |
| 257 | 추가: processed: processed_bytes, | |
| 258 | 추가: total: total_bytes, | |
| 259 | 추가: completed_entries: completed_entries.into(), | |
| 260 | 추가: }, | |
| 261 | 추가: wire::Message::Output { | |
| 262 | 추가: entry_id, | |
| 263 | 추가: relative_name, | |
| 264 | 추가: disposition, | |
| 265 | 추가: } => ui::Event::Output { | |
| 266 | 추가: entry_id, | |
| 267 | 추가: relative_name, | |
| 268 | 추가: disposition: disposition_to_ui(disposition), | |
| 269 | 추가: }, | |
| 270 | 추가: wire::Message::CancelAck { | |
| 271 | 추가: request_sequence, | |
| 272 | 추가: status, | |
| 273 | 추가: } => ui::Event::CancelAck { | |
| 274 | 추가: request_sequence, | |
| 275 | 추가: status: cancel_to_ui(status), | |
| 276 | 추가: }, | |
| 277 | 추가: wire::Message::Terminal(terminal) => ui::Event::Terminal(ui::Terminal { | |
| 278 | 추가: outcome: outcome_to_ui(terminal.outcome), | |
| 279 | 추가: error: error_to_ui(terminal.error), | |
| 280 | 추가: publication: publication_to_ui(terminal.publication), | |
| 281 | 추가: created_count: terminal.created_count, | |
| 282 | 추가: retained_partial_count: terminal.retained_partial_count, | |
| 283 | 추가: durability: durability_to_ui(terminal.durability), | |
| 284 | 추가: cleanup: cleanup_to_ui(terminal.cleanup), | |
| 285 | 추가: }), | |
| 286 | 추가: _ => return Err(()), | |
| 287 | 추가: }) | |
| 288 | 추가: } | |
| 289 | 추가: | |
| 290 | 추가: // 실제 파이프 쓰기는 백그라운드에서 수행하고 UI에서는 한 프레임만 직렬화함. | |
| 291 | 추가: #[derive(Clone, Default)] | |
| 292 | 추가: struct FrameBuffer(Rc<RefCell<Vec<u8>>>); | |
| 293 | 추가: impl Write for FrameBuffer { | |
| 294 | 추가: fn write(&mut self, bytes: &[u8]) -> io::Result<usize> { | |
| 295 | 추가: let mut buffer = self.0.borrow_mut(); | |
| 296 | 추가: if buffer.len().saturating_add(bytes.len()) > codec::MAX_BODY + 32 { | |
| 297 | 추가: return Err(io::Error::other("요청 프레임 한도 초과")); | |
| 298 | 추가: } | |
| 299 | 추가: buffer.extend_from_slice(bytes); | |
| 300 | 추가: Ok(bytes.len()) | |
| 301 | 추가: } | |
| 302 | 추가: fn flush(&mut self) -> io::Result<()> { | |
| 303 | 추가: Ok(()) | |
| 304 | 추가: } | |
| 305 | 추가: } | |
| 306 | 추가: struct Frame(Vec<u8>, bool); | |
| 307 | 추가: impl Drop for Frame { | |
| 308 | 추가: fn drop(&mut self) { | |
| 309 | 추가: self.0.fill(0); | |
| 310 | 추가: } | |
| 311 | 추가: } | |
| 312 | 추가: fn notify(events: &SyncSender<ui::HostEvent>, event: ui::HostEvent) -> bool { | |
| 313 | 추가: events.send(event).is_ok() | |
| 314 | 추가: } | |
| 315 | 추가: fn fault(events: &SyncSender<ui::HostEvent>, stop: &AtomicBool, message: &str) { | |
| 316 | 추가: stop.store(true, Ordering::Release); | |
| 317 | 추가: notify(events, ui::HostEvent::Fault(message.into())); | |
| 318 | 추가: } | |
| 319 | 추가: | |
| 320 | 추가: pub struct ProcessFactory { | |
| 321 | 추가: worker: PathBuf, | |
| 322 | 추가: } | |
| 323 | 추가: impl ProcessFactory { | |
| 324 | 추가: pub fn new(worker: PathBuf) -> Self { | |
| 325 | 추가: Self { worker } | |
| 326 | 추가: } | |
| 327 | 추가: pub fn sibling() -> Result<Self, String> { | |
| 328 | 추가: let executable = | |
| 329 | 추가: std::env::current_exe().map_err(|_| "앱 실행 위치를 확인하지 못했습니다")?; | |
| 330 | 추가: let parent = executable.parent().ok_or("앱 실행 폴더가 없습니다")?; | |
| 331 | 추가: Ok(Self::new(parent.join(if cfg!(windows) { | |
| 332 | 추가: "zipelo-archive-worker.exe" | |
| 333 | 추가: } else { | |
| 334 | 추가: "zipelo-archive-worker" | |
| 335 | 추가: }))) | |
| 336 | 추가: } | |
| 337 | 추가: } | |
| 338 | 추가: impl ui::Factory for ProcessFactory { | |
| 339 | 추가: fn connect(&mut self, job_id: u64) -> Result<Box<dyn ui::Connection>, String> { | |
| 340 | 추가: if !self.worker.is_absolute() || job_id == 0 { | |
| 341 | 추가: return Err("작업자 경로 또는 작업 ID가 올바르지 않습니다".into()); | |
| 342 | 추가: } | |
| 343 | 추가: let (send, requests) = mpsc::sync_channel::<Frame>(8); | |
| 344 | 추가: let (events, receive) = mpsc::sync_channel(64); | |
| 345 | 추가: let (ready, started) = mpsc::sync_channel(1); | |
| 346 | 추가: let stop = Arc::new(AtomicBool::new(false)); | |
| 347 | 추가: let done = Arc::new(AtomicBool::new(false)); | |
| 348 | 추가: let expected = Arc::new(Mutex::new(None)); | |
| 349 | 추가: let worker = self.worker.clone(); | |
| 350 | 추가: let worker_stop = stop.clone(); | |
| 351 | 추가: let worker_done = done.clone(); | |
| 352 | 추가: let worker_expected = expected.clone(); | |
| 353 | 추가: let supervisor = thread::Builder::new() | |
| 354 | 추가: .name("zipelo-worker-owner".into()) | |
| 355 | 추가: .spawn(move || { | |
| 356 | 추가: let mut command = Command::new(worker); | |
| 357 | 추가: command | |
| 358 | 추가: .stdin(Stdio::piped()) | |
| 359 | 추가: .stdout(Stdio::piped()) | |
| 360 | 추가: .stderr(Stdio::piped()); | |
| 361 | 추가: #[cfg(windows)] | |
| 362 | 추가: { | |
| 363 | 추가: use std::os::windows::process::CommandExt; | |
| 364 | 추가: command.creation_flags(0x08000000); | |
| 365 | 추가: } | |
| 366 | 추가: let child = match command.spawn() { | |
| 367 | 추가: Ok(child) => child, | |
| 368 | 추가: Err(_) => { | |
| 369 | 추가: let _ = ready.send(Err( | |
| 370 | 추가: "작업자를 실행하지 못했습니다. 앱과 작업자를 함께 설치하세요" | |
| 371 | 추가: .to_string(), | |
| 372 | 추가: )); | |
| 373 | 추가: return; | |
| 374 | 추가: } | |
| 375 | 추가: }; | |
| 376 | 추가: if ready.send(Ok(())).is_err() { | |
| 377 | 추가: let mut child = child; | |
| 378 | 추가: let _ = child.kill(); | |
| 379 | 추가: let _ = child.wait(); | |
| 380 | 추가: return; | |
| 381 | 추가: } | |
| 382 | 추가: supervise( | |
| 383 | 추가: child, | |
| 384 | 추가: job_id, | |
| 385 | 추가: requests, | |
| 386 | 추가: events, | |
| 387 | 추가: worker_stop, | |
| 388 | 추가: worker_done, | |
| 389 | 추가: worker_expected, | |
| 390 | 추가: ); | |
| 391 | 추가: }) | |
| 392 | 추가: .map_err(|_| "작업자 관리 스레드를 시작하지 못했습니다")?; | |
| 393 | 추가: match started.recv() { | |
| 394 | 추가: Ok(Ok(())) => { | |
| 395 | 추가: let buffer = FrameBuffer::default(); | |
| 396 | 추가: Ok(Box::new(ProcessConnection { | |
| 397 | 추가: job_id, | |
| 398 | 추가: next: 0, | |
| 399 | 추가: writer: codec::Writer::new(buffer.clone(), job_id), | |
| 400 | 추가: buffer, | |
| 401 | 추가: send: Some(send), | |
| 402 | 추가: receive: Some(receive), | |
| 403 | 추가: stop, | |
| 404 | 추가: supervisor: Some(supervisor), | |
| 405 | 추가: expected, | |
| 406 | 추가: done, | |
| 407 | 추가: disconnected: false, | |
| 408 | 추가: reaped: false, | |
| 409 | 추가: })) | |
| 410 | 추가: } | |
| 411 | 추가: result => { | |
| 412 | 추가: stop.store(true, Ordering::Release); | |
| 413 | 추가: drop(send); | |
| 414 | 추가: drop(receive); | |
| 415 | 추가: let _ = supervisor.join(); | |
| 416 | 추가: Err(result | |
| 417 | 추가: .ok() | |
| 418 | 추가: .and_then(Result::err) | |
| 419 | 추가: .unwrap_or_else(|| "작업자 시작 결과가 없습니다".into())) | |
| 420 | 추가: } | |
| 421 | 추가: } | |
| 422 | 추가: } | |
| 423 | 추가: } | |
| 424 | 추가: struct ProcessConnection { | |
| 425 | 추가: job_id: u64, | |
| 426 | 추가: next: u64, | |
| 427 | 추가: writer: codec::Writer<FrameBuffer>, | |
| 428 | 추가: buffer: FrameBuffer, | |
| 429 | 추가: send: Option<SyncSender<Frame>>, | |
| 430 | 추가: receive: Option<Receiver<ui::HostEvent>>, | |
| 431 | 추가: stop: Arc<AtomicBool>, | |
| 432 | 추가: supervisor: Option<JoinHandle<()>>, | |
| 433 | 추가: expected: Arc<Mutex<Option<wire::ActionKind>>>, | |
| 434 | 추가: done: Arc<AtomicBool>, | |
| 435 | 추가: disconnected: bool, | |
| 436 | 추가: reaped: bool, | |
| 437 | 추가: } | |
| 438 | 추가: impl ui::Connection for ProcessConnection { | |
| 439 | 추가: fn send(&mut self, request: ui::Request) -> Result<(), String> { | |
| 440 | 추가: if self.stop.load(Ordering::Acquire) | |
| 441 | 추가: || request.job_id != self.job_id | |
| 442 | 추가: || request.sequence != self.next | |
| 443 | 추가: || self.next >= codec::MAX_FRAMES | |
| 444 | 추가: { | |
| 445 | 추가: self.stop.store(true, Ordering::Release); | |
| 446 | 추가: return Err("작업자 요청 채널이 닫혔거나 순서가 올바르지 않습니다".into()); | |
| 447 | 추가: } | |
| 448 | 추가: let is_cancel = matches!(request.command, ui::Command::Cancel); | |
| 449 | 추가: let message = match request.command { | |
| 450 | 추가: ui::Command::Start(start) => { | |
| 451 | 추가: let start = start_to_wire(start); | |
| 452 | 추가: *self.expected.lock().map_err(|_| { | |
| 453 | 추가: self.stop.store(true, Ordering::Release); | |
| 454 | 추가: "작업자 요청 상태 오류" | |
| 455 | 추가: })? = Some(start.action.kind()); | |
| 456 | 추가: wire::Message::Start(start) | |
| 457 | 추가: } | |
| 458 | 추가: ui::Command::Cancel => wire::Message::Cancel, | |
| 459 | 추가: ui::Command::Password { | |
| 460 | 추가: challenge_id, | |
| 461 | 추가: secret, | |
| 462 | 추가: } => wire::Message::Password { | |
| 463 | 추가: challenge_id, | |
| 464 | 추가: secret: wire::Secret(secret.as_bytes().to_vec()), | |
| 465 | 추가: }, | |
| 466 | 추가: }; | |
| 467 | 추가: if self.writer.send(&message).is_err() { | |
| 468 | 추가: self.buffer.0.borrow_mut().fill(0); | |
| 469 | 추가: self.buffer.0.borrow_mut().clear(); | |
| 470 | 추가: self.stop.store(true, Ordering::Release); | |
| 471 | 추가: return Err("작업자 요청을 직렬화하지 못했습니다".into()); | |
| 472 | 추가: } | |
| 473 | 추가: let bytes = Frame(std::mem::take(&mut *self.buffer.0.borrow_mut()), is_cancel); | |
| 474 | 추가: if self.send.as_ref().unwrap().try_send(bytes).is_err() { | |
| 475 | 추가: if is_cancel && self.done.load(Ordering::Acquire) { | |
| 476 | 추가: self.next += 1; | |
| 477 | 추가: return Ok(()); | |
| 478 | 추가: } | |
| 479 | 추가: self.stop.store(true, Ordering::Release); | |
| 480 | 추가: return Err("작업자 요청 대기열이 닫혔거나 가득 찼습니다".into()); | |
| 481 | 추가: } | |
| 482 | 추가: self.next += 1; | |
| 483 | 추가: Ok(()) | |
| 484 | 추가: } | |
| 485 | 추가: fn poll(&mut self) -> Option<ui::HostEvent> { | |
| 486 | 추가: match self.receive.as_ref()?.try_recv() { | |
| 487 | 추가: Ok(event) => { | |
| 488 | 추가: if matches!(event, ui::HostEvent::Exited { .. }) { | |
| 489 | 추가: self.reaped = true; | |
| 490 | 추가: } | |
| 491 | 추가: Some(event) | |
| 492 | 추가: } | |
| 493 | 추가: Err(mpsc::TryRecvError::Empty) => None, | |
| 494 | 추가: Err(mpsc::TryRecvError::Disconnected) if !self.reaped && !self.disconnected => { | |
| 495 | 추가: self.disconnected = true; | |
| 496 | 추가: Some(ui::HostEvent::Fault( | |
| 497 | 추가: "작업자 통신 스레드가 종료됐습니다".into(), | |
| 498 | 추가: )) | |
| 499 | 추가: } | |
| 500 | 추가: Err(_) => None, | |
| 501 | 추가: } | |
| 502 | 추가: } | |
| 503 | 추가: } | |
| 504 | 추가: impl Drop for ProcessConnection { | |
| 505 | 추가: fn drop(&mut self) { | |
| 506 | 추가: self.stop.store(true, Ordering::Release); | |
| 507 | 추가: self.send.take(); | |
| 508 | 추가: self.receive.take(); | |
| 509 | 추가: if let Some(supervisor) = self.supervisor.take() { | |
| 510 | 추가: let _ = supervisor.join(); | |
| 511 | 추가: } | |
| 512 | 추가: } | |
| 513 | 추가: } | |
| 514 | 추가: | |
| 515 | 추가: fn supervise( | |
| 516 | 추가: mut child: std::process::Child, | |
| 517 | 추가: job_id: u64, | |
| 518 | 추가: requests: Receiver<Frame>, | |
| 519 | 추가: events: SyncSender<ui::HostEvent>, | |
| 520 | 추가: stop: Arc<AtomicBool>, | |
| 521 | 추가: done: Arc<AtomicBool>, | |
| 522 | 추가: expected: Arc<Mutex<Option<wire::ActionKind>>>, | |
| 523 | 추가: ) { | |
| 524 | 추가: let mut input = child.stdin.take().unwrap(); | |
| 525 | 추가: let mut output = child.stdout.take().unwrap(); | |
| 526 | 추가: let mut errors = child.stderr.take().unwrap(); | |
| 527 | 추가: let mut threads = Vec::new(); | |
| 528 | 추가: let cancel_write_failed = Arc::new(AtomicBool::new(false)); | |
| 529 | 추가: let terminal_received = Arc::new(AtomicBool::new(false)); | |
| 530 | 추가: let failed_cancel = cancel_write_failed.clone(); | |
| 531 | 추가: let tx = events.clone(); | |
| 532 | 추가: let abort = stop.clone(); | |
| 533 | 추가: let finished = done.clone(); | |
| 534 | 추가: threads.push( | |
| 535 | 추가: thread::Builder::new() | |
| 536 | 추가: .name("zipelo-worker-input".into()) | |
| 537 | 추가: .spawn(move || { | |
| 538 | 추가: while !finished.load(Ordering::Acquire) && !abort.load(Ordering::Acquire) { | |
| 539 | 추가: match requests.recv_timeout(Duration::from_millis(10)) { | |
| 540 | 추가: Ok(frame) => { | |
| 541 | 추가: if input | |
| 542 | 추가: .write_all(&frame.0) | |
| 543 | 추가: .and_then(|_| input.flush()) | |
| 544 | 추가: .is_err() | |
| 545 | 추가: { | |
| 546 | 추가: if frame.1 { | |
| 547 | 추가: // 취소 쓰기 실패는 응답과 실제 종료 결과를 확인한 뒤 판단함. | |
| 548 | 추가: failed_cancel.store(true, Ordering::Release); | |
| 549 | 추가: } else { | |
| 550 | 추가: fault(&tx, &abort, "작업자 요청 파이프 쓰기에 실패했습니다"); | |
| 551 | 추가: } | |
| 552 | 추가: break; | |
| 553 | 추가: } | |
| 554 | 추가: } | |
| 555 | 추가: Err(mpsc::RecvTimeoutError::Timeout) => {} | |
| 556 | 추가: Err(_) => break, | |
| 557 | 추가: } | |
| 558 | 추가: } | |
| 559 | 추가: }), | |
| 560 | 추가: ); | |
| 561 | 추가: let tx = events.clone(); | |
| 562 | 추가: let abort = stop.clone(); | |
| 563 | 추가: let received_terminal = terminal_received.clone(); | |
| 564 | 추가: threads.push( | |
| 565 | 추가: thread::Builder::new() | |
| 566 | 추가: .name("zipelo-worker-output".into()) | |
| 567 | 추가: .spawn(move || { | |
| 568 | 추가: let eof; | |
| 569 | 추가: { | |
| 570 | 추가: let mut reader = codec::Reader::new(&mut output); | |
| 571 | 추가: eof = loop { | |
| 572 | 추가: match reader.read() { | |
| 573 | 추가: Ok(Some((job, sequence, message))) => { | |
| 574 | 추가: let action = expected.lock().ok().and_then(|value| *value); | |
| 575 | 추가: let event = event_to_ui(message, action); | |
| 576 | 추가: if job != job_id || event.is_err() { | |
| 577 | 추가: fault(&tx, &abort, "작업자 응답이 요청과 일치하지 않습니다"); | |
| 578 | 추가: break false; | |
| 579 | 추가: } | |
| 580 | 추가: if matches!(event, Ok(ui::Event::Terminal(_))) { | |
| 581 | 추가: received_terminal.store(true, Ordering::Release); | |
| 582 | 추가: } | |
| 583 | 추가: if !notify( | |
| 584 | 추가: &tx, | |
| 585 | 추가: ui::HostEvent::Frame { | |
| 586 | 추가: job_id: job, | |
| 587 | 추가: sequence, | |
| 588 | 추가: event: event.unwrap(), | |
| 589 | 추가: }, | |
| 590 | 추가: ) { | |
| 591 | 추가: return; | |
| 592 | 추가: } | |
| 593 | 추가: } | |
| 594 | 추가: Ok(None) => break true, | |
| 595 | 추가: Err(_) => { | |
| 596 | 추가: fault(&tx, &abort, "작업자 응답 프레임을 읽지 못했습니다"); | |
| 597 | 추가: break false; | |
| 598 | 추가: } | |
| 599 | 추가: } | |
| 600 | 추가: }; | |
| 601 | 추가: } | |
| 602 | 추가: if eof || io::copy(&mut output, &mut io::sink()).is_ok() { | |
| 603 | 추가: notify(&tx, ui::HostEvent::StdoutEof); | |
| 604 | 추가: } | |
| 605 | 추가: }), | |
| 606 | 추가: ); | |
| 607 | 추가: let tx = events.clone(); | |
| 608 | 추가: let abort = stop.clone(); | |
| 609 | 추가: threads.push( | |
| 610 | 추가: thread::Builder::new() | |
| 611 | 추가: .name("zipelo-worker-errors".into()) | |
| 612 | 추가: .spawn(move || { | |
| 613 | 추가: let mut bytes = [0u8; 4096]; | |
| 614 | 추가: loop { | |
| 615 | 추가: match errors.read(&mut bytes) { | |
| 616 | 추가: Ok(0) => { | |
| 617 | 추가: notify(&tx, ui::HostEvent::StderrEof); | |
| 618 | 추가: break; | |
| 619 | 추가: } | |
| 620 | 추가: Ok(_) => {} | |
| 621 | 추가: Err(error) if error.kind() == io::ErrorKind::Interrupted => {} | |
| 622 | 추가: Err(_) => { | |
| 623 | 추가: fault(&tx, &abort, "작업자 오류 파이프를 읽지 못했습니다"); | |
| 624 | 추가: break; | |
| 625 | 추가: } | |
| 626 | 추가: } | |
| 627 | 추가: } | |
| 628 | 추가: }), | |
| 629 | 추가: ); | |
| 630 | 추가: let mut handles = Vec::new(); | |
| 631 | 추가: for result in threads { | |
| 632 | 추가: match result { | |
| 633 | 추가: Ok(handle) => handles.push(handle), | |
| 634 | 추가: Err(_) => fault(&events, &stop, "작업자 통신 스레드를 시작하지 못했습니다"), | |
| 635 | 추가: } | |
| 636 | 추가: } | |
| 637 | 추가: let started = Instant::now(); | |
| 638 | 추가: let status = loop { | |
| 639 | 추가: if started.elapsed() >= Duration::from_secs(310) { | |
| 640 | 추가: fault(&events, &stop, "작업자 처리 제한 시간을 초과했습니다"); | |
| 641 | 추가: } | |
| 642 | 추가: if stop.load(Ordering::Acquire) { | |
| 643 | 추가: let _ = child.kill(); | |
| 644 | 추가: } | |
| 645 | 추가: match child.try_wait() { | |
| 646 | 추가: Ok(Some(status)) => break Some(status), | |
| 647 | 추가: Ok(None) => thread::sleep(Duration::from_millis(10)), | |
| 648 | 추가: Err(_) => { | |
| 649 | 추가: fault(&events, &stop, "작업자 종료 상태를 확인하지 못했습니다"); | |
| 650 | 추가: let _ = child.kill(); | |
| 651 | 추가: break child.wait().ok(); | |
| 652 | 추가: } | |
| 653 | 추가: } | |
| 654 | 추가: }; | |
| 655 | 추가: done.store(true, Ordering::Release); | |
| 656 | 추가: for handle in handles { | |
| 657 | 추가: if handle.join().is_err() { | |
| 658 | 추가: fault(&events, &stop, "작업자 통신 스레드 회수에 실패했습니다"); | |
| 659 | 추가: } | |
| 660 | 추가: } | |
| 661 | 추가: if cancel_write_failed.load(Ordering::Acquire) | |
| 662 | 추가: && !(terminal_received.load(Ordering::Acquire) | |
| 663 | 추가: && status.as_ref().is_some_and(|status| status.success())) | |
| 664 | 추가: { | |
| 665 | 추가: fault(&events, &stop, "작업자 요청 파이프 쓰기에 실패했습니다"); | |
| 666 | 추가: } | |
| 667 | 추가: if let Some(status) = status { | |
| 668 | 추가: // 회수와 모든 파이프 핸들 정리가 끝난 뒤에만 닫기 허용 근거를 전달함. | |
| 669 | 추가: notify(&events, ui::HostEvent::CleanupComplete); | |
| 670 | 추가: notify( | |
| 671 | 추가: &events, | |
| 672 | 추가: ui::HostEvent::Exited { | |
| 673 | 추가: success: status.success(), | |
| 674 | 추가: }, | |
| 675 | 추가: ); | |
| 676 | 추가: } | |
| 677 | 추가: } |
| @@ -6,6 +6,7 @@ pub enum Format { | ||
| 6 | 6 | Tar, |
| 7 | 7 | Gzip, |
| 8 | 8 | TarGzip, |
| 9 | 추가: SevenZip, | |
| 9 | 10 | } |
| 10 | 11 | #[derive(Clone, Debug, Eq, PartialEq)] |
| 11 | 12 | pub enum SourceObject { |
| @@ -200,6 +201,8 @@ pub enum Event { | ||
| 200 | 201 | Terminal(Terminal), |
| 201 | 202 | } |
| 202 | 203 | pub enum HostEvent { |
| 204 | 추가: Fault(String), | |
| 205 | 추가: CleanupComplete, | |
| 203 | 206 | Frame { |
| 204 | 207 | job_id: u64, |
| 205 | 208 | sequence: u64, |
| @@ -237,6 +240,7 @@ struct Running { | ||
| 237 | 240 | entries: Vec<Entry>, |
| 238 | 241 | list_end: Option<(u32, ListId)>, |
| 239 | 242 | stdout_eof: bool, |
| 243 | 추가: transport_closed: bool, | |
| 240 | 244 | stderr_eof: bool, |
| 241 | 245 | exit: Option<bool>, |
| 242 | 246 | cancel_sequence: Option<u64>, |
| @@ -380,6 +384,7 @@ impl Model { | ||
| 380 | 384 | entries: Vec::new(), |
| 381 | 385 | list_end: None, |
| 382 | 386 | stdout_eof: false, |
| 387 | 추가: transport_closed: false, | |
| 383 | 388 | stderr_eof: false, |
| 384 | 389 | exit: None, |
| 385 | 390 | cancel_sequence: None, |
| @@ -509,10 +514,10 @@ impl Model { | ||
| 509 | 514 | }; |
| 510 | 515 | self.receive(event); |
| 511 | 516 | } |
| 512 | 삭제: let complete = self | |
| 513 | 삭제: .running | |
| 514 | 삭제: .as_ref() | |
| 515 | 삭제: .is_some_and(|r| r.stdout_eof && r.stderr_eof && r.exit.is_some()); | |
| 517 | 추가: let complete = self.running.as_ref().is_some_and(|r| { | |
| 518 | 추가: r.exit.is_some() | |
| 519 | 추가: && ((r.stdout_eof && r.stderr_eof) || (r.transport_closed && self.error.is_some())) | |
| 520 | 추가: }); | |
| 516 | 521 | if complete { |
| 517 | 522 | let run = self.running.take().unwrap(); |
| 518 | 523 | self.confirmed = |
| @@ -559,6 +564,8 @@ impl Model { | ||
| 559 | 564 | fn receive(&mut self, host: HostEvent) { |
| 560 | 565 | let run = self.running.as_mut().unwrap(); |
| 561 | 566 | match host { |
| 567 | 추가: HostEvent::Fault(message) => self.error = Some(message), | |
| 568 | 추가: HostEvent::CleanupComplete => run.transport_closed = true, | |
| 562 | 569 | HostEvent::StdoutEof => run.stdout_eof = true, |
| 563 | 570 | HostEvent::StderrEof => run.stderr_eof = true, |
| 564 | 571 | HostEvent::Exited { success } => run.exit = Some(success), |
| @@ -58,7 +58,10 @@ fn main() -> eframe::Result { | ||
| 58 | 58 | ))); |
| 59 | 59 | } |
| 60 | 60 | } else { |
| 61 | 삭제: Box::new(zipelo_ui_memory_app::archive_ui::Unavailable) | |
| 61 | 추가: Box::new( | |
| 62 | 추가: zipelo_ui_memory_app::archive_process::ProcessFactory::sibling() | |
| 63 | 추가: .map_err(std::io::Error::other)?, | |
| 64 | 추가: ) | |
| 62 | 65 | }; |
| 63 | 66 | Ok(Box::new( |
| 64 | 67 | zipelo_ui_memory_app::archive_screen::ArchiveApp::new(factory, startup, fixture), |
| @@ -9,3 +9,5 @@ pub mod archive_ui; | ||
| 9 | 9 | |
| 10 | 10 | #[cfg(feature = "ui")] |
| 11 | 11 | pub mod archive_screen; |
| 12 | 추가: | |
| 13 | 추가: pub mod archive_process; |
| @@ -0,0 +1 @@ | ||
| 1 | 추가: runs/ |
| @@ -0,0 +1,107 @@ | ||
| 1 | 추가: # This file is automatically @generated by Cargo. | |
| 2 | 추가: # It is not intended for manual editing. | |
| 3 | 추가: version = 4 | |
| 4 | 추가: | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "block-buffer" | |
| 7 | 추가: version = "0.10.4" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" | |
| 10 | 추가: dependencies = [ | |
| 11 | 추가: "generic-array", | |
| 12 | 추가: ] | |
| 13 | 추가: | |
| 14 | 추가: [[package]] | |
| 15 | 추가: name = "cfg-if" | |
| 16 | 추가: version = "1.0.5" | |
| 17 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 18 | 추가: checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" | |
| 19 | 추가: | |
| 20 | 추가: [[package]] | |
| 21 | 추가: name = "cpufeatures" | |
| 22 | 추가: version = "0.2.17" | |
| 23 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 24 | 추가: checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" | |
| 25 | 추가: dependencies = [ | |
| 26 | 추가: "libc", | |
| 27 | 추가: ] | |
| 28 | 추가: | |
| 29 | 추가: [[package]] | |
| 30 | 추가: name = "crypto-common" | |
| 31 | 추가: version = "0.1.7" | |
| 32 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 33 | 추가: checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" | |
| 34 | 추가: dependencies = [ | |
| 35 | 추가: "generic-array", | |
| 36 | 추가: "typenum", | |
| 37 | 추가: ] | |
| 38 | 추가: | |
| 39 | 추가: [[package]] | |
| 40 | 추가: name = "digest" | |
| 41 | 추가: version = "0.10.7" | |
| 42 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 43 | 추가: checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" | |
| 44 | 추가: dependencies = [ | |
| 45 | 추가: "block-buffer", | |
| 46 | 추가: "crypto-common", | |
| 47 | 추가: ] | |
| 48 | 추가: | |
| 49 | 추가: [[package]] | |
| 50 | 추가: name = "generic-array" | |
| 51 | 추가: version = "0.14.7" | |
| 52 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 53 | 추가: checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" | |
| 54 | 추가: dependencies = [ | |
| 55 | 추가: "typenum", | |
| 56 | 추가: "version_check", | |
| 57 | 추가: ] | |
| 58 | 추가: | |
| 59 | 추가: [[package]] | |
| 60 | 추가: name = "libc" | |
| 61 | 추가: version = "0.2.191" | |
| 62 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 63 | 추가: checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" | |
| 64 | 추가: | |
| 65 | 추가: [[package]] | |
| 66 | 추가: name = "sha2" | |
| 67 | 추가: version = "0.10.9" | |
| 68 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 69 | 추가: checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" | |
| 70 | 추가: dependencies = [ | |
| 71 | 추가: "cfg-if", | |
| 72 | 추가: "cpufeatures", | |
| 73 | 추가: "digest", | |
| 74 | 추가: ] | |
| 75 | 추가: | |
| 76 | 추가: [[package]] | |
| 77 | 추가: name = "typenum" | |
| 78 | 추가: version = "1.20.1" | |
| 79 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 80 | 추가: checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" | |
| 81 | 추가: | |
| 82 | 추가: [[package]] | |
| 83 | 추가: name = "version_check" | |
| 84 | 추가: version = "0.9.5" | |
| 85 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 86 | 추가: checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" | |
| 87 | 추가: | |
| 88 | 추가: [[package]] | |
| 89 | 추가: name = "zipelo-archive-worker" | |
| 90 | 추가: version = "0.1.0" | |
| 91 | 추가: dependencies = [ | |
| 92 | 추가: "sha2", | |
| 93 | 추가: "zlib-rs", | |
| 94 | 추가: ] | |
| 95 | 추가: | |
| 96 | 추가: [[package]] | |
| 97 | 추가: name = "zipelo-real-worker-probe" | |
| 98 | 추가: version = "0.1.0" | |
| 99 | 추가: dependencies = [ | |
| 100 | 추가: "zipelo-archive-worker", | |
| 101 | 추가: ] | |
| 102 | 추가: | |
| 103 | 추가: [[package]] | |
| 104 | 추가: name = "zlib-rs" | |
| 105 | 추가: version = "0.6.8" | |
| 106 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 107 | 추가: checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| @@ -0,0 +1,19 @@ | ||
| 1 | 추가: [package] | |
| 2 | 추가: name = "zipelo-real-worker-probe" | |
| 3 | 추가: version = "0.1.0" | |
| 4 | 추가: edition = "2024" | |
| 5 | 추가: rust-version = "1.99" | |
| 6 | 추가: license = "MIT" | |
| 7 | 추가: publish = false | |
| 8 | 추가: autotests = false | |
| 9 | 추가: | |
| 10 | 추가: [workspace] | |
| 11 | 추가: | |
| 12 | 추가: [dependencies] | |
| 13 | 추가: worker_protocol = { package = "zipelo-archive-worker", path = "../../experiments/rust-archive-worker" } | |
| 14 | 추가: | |
| 15 | 추가: [[bin]] | |
| 16 | 추가: name = "zipelo-real-worker-probe" | |
| 17 | 추가: path = "probe.rs" | |
| 18 | 추가: test = false | |
| 19 | 추가: bench = false |
| @@ -0,0 +1,58 @@ | ||
| 1 | 추가: # 실제 작업자와 화면 연결 시험 | |
| 2 | 추가: | |
| 3 | 추가: 기본 앱은 실행 파일과 같은 폴더의 zipelo-archive-worker(Windows는 .exe)를 실행함. | |
| 4 | 추가: PATH나 현재 작업 폴더에서 임의 작업자를 검색하지 않음. ui-fixture와 --ui-fixture가 | |
| 5 | 추가: 모두 지정된 경우에만 기존 가짜 작업자를 사용함. | |
| 6 | 추가: | |
| 7 | 추가: 클라이언트는 작업자 crate의 protocol과 wire codec을 재사용하며 압축 처리와 파일 접근은 | |
| 8 | 추가: 별도 작업자 프로세스에서 수행함. UI에서 파이프 쓰기를 기다리지 않도록 8프레임 요청 큐와 | |
| 9 | 추가: 64이벤트 응답 큐를 사용함. 파이프 입출력과 child wait는 백그라운드에서 처리함. | |
| 10 | 추가: 정상 종료에는 Terminal, 양쪽 EOF와 child wait를 모두 확인함. 통신 오류는 성공으로 | |
| 11 | 추가: 표시하지 않으며, 오류 경로에서는 child 회수와 모든 파이프 스레드/핸들 정리가 끝났다는 | |
| 12 | 추가: 명시적 완료 신호까지 확인함. 연결이 예외적으로 폐기돼도 소유한 자식을 종료하고 회수함. | |
| 13 | 추가: 310초 제한 시간을 넘긴 작업자도 종료와 회수를 시도하며 완료 여부가 불명확하면 닫기를 허용하지 않음. | |
| 14 | 추가: | |
| 15 | 추가: ## 실행 | |
| 16 | 추가: | |
| 17 | 추가: 저장소 루트에서 로컬 실행기를 사용하면 실제 작업자와 probe 빌드가 화면 시험보다 먼저 수행됨. | |
| 18 | 추가: | |
| 19 | 추가: ```sh | |
| 20 | 추가: python3 tests/ci/run_rust.py local | |
| 21 | 추가: ``` | |
| 22 | 추가: | |
| 23 | 추가: 단독 시험에서는 같은 target 디렉터리에 먼저 두 실행 파일을 빌드할 것. | |
| 24 | 추가: | |
| 25 | 추가: ```sh | |
| 26 | 추가: export CARGO_TARGET_DIR="$PWD/tests/ci/target" | |
| 27 | 추가: cargo +1.99.1 build --locked --manifest-path experiments/rust-archive-worker/Cargo.toml | |
| 28 | 추가: cargo +1.99.1 build --locked --manifest-path tests/rust-app-real-worker/Cargo.toml | |
| 29 | 추가: cargo +1.99.1 test --locked --all-features --manifest-path experiments/rust-ui-memory-app/Cargo.toml --test real_worker | |
| 30 | 추가: ``` | |
| 31 | 추가: | |
| 32 | 추가: 기본 앱의 직접 실행도 같은 target 디렉터리를 사용할 것. | |
| 33 | 추가: | |
| 34 | 추가: ```sh | |
| 35 | 추가: cargo +1.99.1 run --locked --manifest-path experiments/rust-ui-memory-app/Cargo.toml --features ui -- /absolute/sample.zip | |
| 36 | 추가: ``` | |
| 37 | 추가: | |
| 38 | 추가: ## 확인 범위 | |
| 39 | 추가: | |
| 40 | 추가: - 합성 ZIP과 TAR.GZ를 실제 파일 열기 위젯으로 열고 목록을 확인한 뒤 풀기 버튼으로 해제함. | |
| 41 | 추가: - ZIP 만들기 위젯으로 합성 파일을 압축하고, 결과를 다시 열고 풀어 바이트가 같은지 확인함. | |
| 42 | 추가: - 위 세 흐름은 실제 작업자 EXE와 OS 파이프를 사용하며 Terminal, 양쪽 EOF, child wait와 연결 정리 순서를 관측함. | |
| 43 | 추가: - 누락된 작업자, 잘린 프레임, 잘못된 action 승인, Terminal 없는 조기 종료를 오류로 처리함. | |
| 44 | 추가: - 첫 Start 직렬화 실패도 실제 작업자 회수까지 대기함. Linux에서는 실행 중인 probe 연결을 폐기한 후 /proc에서 소유 자식이 사라진 것도 확인함. | |
| 45 | 추가: - flows.rs의 창은 egui Context에서 실제 위젯에 포인터와 키보드 이벤트를 전달함. 네이티브 OS 창/입력 자동화나 Windows 실행 검증은 아님. | |
| 46 | 추가: | |
| 47 | 추가: fixtures/는 generate.py의 Python 표준 라이브러리로 생성한 작은 합성 입력임. | |
| 48 | 추가: 정상 흐름은 제품 작업자를 사용하고, probe.rs는 통신 실패와 생명주기 시험 전용임. | |
| 49 | 추가: 사용자 자료를 읽거나 출력하지 않으며 모든 시험 출력은 이 폴더의 runs/ 안에만 생성함. | |
| 50 | 추가: 암호 ZIP, 대용량 성능, OS sandbox, 악성 파일 전체 검증과 Windows 실기는 이 시험의 범위 밖임. | |
| 51 | 추가: | |
| 52 | 추가: 취소와 종료 경합 회귀 시험은 실제 작업자에 List를 보낸 뒤 화면 poll 전에 취소하는 흐름을 100회 확인함. 취소 파이프 쓰기가 실패해도 검증된 Terminal과 성공 종료가 있으면 원래 결과를 보존하며, Terminal이 없는 조기 종료는 계속 실패로 처리함. 취소 쓰기 오류 판단을 미루어도 EOF와 child wait 전에는 닫기나 작업 교체를 허용하지 않음. | |
| 53 | 추가: | |
| 54 | 추가: 7z 앱 연동은 revision 2의 기존 Format 값 0~3을 유지하고 SevenZip 값 4를 추가함. | |
| 55 | 추가: formats.rs는 전체 ListEnd 프레임을 고정 바이트와 비교하고 Unix/Windows 식별자가 | |
| 56 | 추가: 목록 응답과 해제 요청 사이에서 보존되는지 확인함. 화면 흐름 시험은 PR69의 LZMA와 | |
| 57 | 추가: LZMA2 표본을 실제 작업자로 열고, 받은 ListId로 풀어 원본 바이트를 확인함. | |
| 58 | 추가: 구버전 앱은 새 형식 값을 해석할 수 없으므로 앱과 작업자를 함께 갱신해야 함. |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기| @@ -0,0 +1,552 @@ | ||
| 1 | 추가: use std::{ | |
| 2 | 추가: cell::RefCell, | |
| 3 | 추가: fs, | |
| 4 | 추가: path::{Path, PathBuf}, | |
| 5 | 추가: rc::Rc, | |
| 6 | 추가: sync::atomic::{AtomicU64, Ordering}, | |
| 7 | 추가: time::{Duration, Instant}, | |
| 8 | 추가: }; | |
| 9 | 추가: use zipelo_ui_memory_app::{archive_process::ProcessFactory, archive_ui::*}; | |
| 10 | 추가: static NEXT: AtomicU64 = AtomicU64::new(0); | |
| 11 | 추가: struct Scratch(PathBuf); | |
| 12 | 추가: impl Scratch { | |
| 13 | 추가: fn new() -> Self { | |
| 14 | 추가: let root = | |
| 15 | 추가: Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/rust-app-real-worker/runs"); | |
| 16 | 추가: fs::create_dir_all(&root).unwrap(); | |
| 17 | 추가: let path = root.join(format!( | |
| 18 | 추가: "{}-{}", | |
| 19 | 추가: std::process::id(), | |
| 20 | 추가: NEXT.fetch_add(1, Ordering::Relaxed) | |
| 21 | 추가: )); | |
| 22 | 추가: Self(make_directory(&path)) | |
| 23 | 추가: } | |
| 24 | 추가: fn path(&self, name: &str) -> PathBuf { | |
| 25 | 추가: self.0.join(name) | |
| 26 | 추가: } | |
| 27 | 추가: } | |
| 28 | 추가: impl Drop for Scratch { | |
| 29 | 추가: fn drop(&mut self) { | |
| 30 | 추가: fs::remove_dir_all(&self.0).unwrap(); | |
| 31 | 추가: } | |
| 32 | 추가: } | |
| 33 | 추가: fn make_directory(path: &Path) -> PathBuf { | |
| 34 | 추가: let mut builder = fs::DirBuilder::new(); | |
| 35 | 추가: #[cfg(unix)] | |
| 36 | 추가: { | |
| 37 | 추가: use std::os::unix::fs::DirBuilderExt; | |
| 38 | 추가: builder.mode(0o700); | |
| 39 | 추가: } | |
| 40 | 추가: builder.create(path).unwrap(); | |
| 41 | 추가: path.canonicalize().unwrap() | |
| 42 | 추가: } | |
| 43 | 추가: fn binary(name: &str) -> PathBuf { | |
| 44 | 추가: let current = std::env::current_exe().unwrap(); | |
| 45 | 추가: let path = current | |
| 46 | 추가: .parent() | |
| 47 | 추가: .unwrap() | |
| 48 | 추가: .parent() | |
| 49 | 추가: .unwrap() | |
| 50 | 추가: .join(format!("{name}{}", std::env::consts::EXE_SUFFIX)); | |
| 51 | 추가: assert!( | |
| 52 | 추가: path.is_file(), | |
| 53 | 추가: "실제 작업자와 시험 probe를 먼저 빌드해야 함: {}", | |
| 54 | 추가: path.display() | |
| 55 | 추가: ); | |
| 56 | 추가: path | |
| 57 | 추가: } | |
| 58 | 추가: #[derive(Default)] | |
| 59 | 추가: struct Observation { | |
| 60 | 추가: jobs: Vec<Vec<&'static str>>, | |
| 61 | 추가: } | |
| 62 | 추가: struct ObservedFactory { | |
| 63 | 추가: process: ProcessFactory, | |
| 64 | 추가: observed: Rc<RefCell<Observation>>, | |
| 65 | 추가: } | |
| 66 | 추가: struct ObservedConnection { | |
| 67 | 추가: connection: Box<dyn Connection>, | |
| 68 | 추가: index: usize, | |
| 69 | 추가: observed: Rc<RefCell<Observation>>, | |
| 70 | 추가: } | |
| 71 | 추가: impl Factory for ObservedFactory { | |
| 72 | 추가: fn connect(&mut self, job: u64) -> Result<Box<dyn Connection>, String> { | |
| 73 | 추가: let connection = self.process.connect(job)?; | |
| 74 | 추가: let index = self.observed.borrow().jobs.len(); | |
| 75 | 추가: self.observed.borrow_mut().jobs.push(Vec::new()); | |
| 76 | 추가: Ok(Box::new(ObservedConnection { | |
| 77 | 추가: connection, | |
| 78 | 추가: index, | |
| 79 | 추가: observed: self.observed.clone(), | |
| 80 | 추가: })) | |
| 81 | 추가: } | |
| 82 | 추가: } | |
| 83 | 추가: impl Connection for ObservedConnection { | |
| 84 | 추가: fn send(&mut self, request: Request) -> Result<(), String> { | |
| 85 | 추가: self.connection.send(request) | |
| 86 | 추가: } | |
| 87 | 추가: fn poll(&mut self) -> Option<HostEvent> { | |
| 88 | 추가: let event = self.connection.poll()?; | |
| 89 | 추가: let label = match &event { | |
| 90 | 추가: HostEvent::StdoutEof => "stdout", | |
| 91 | 추가: HostEvent::StderrEof => "stderr", | |
| 92 | 추가: HostEvent::Exited { .. } => "wait", | |
| 93 | 추가: HostEvent::CleanupComplete => "cleanup", | |
| 94 | 추가: HostEvent::Fault(_) => "fault", | |
| 95 | 추가: HostEvent::Frame { | |
| 96 | 추가: event: Event::Terminal(_), | |
| 97 | 추가: .. | |
| 98 | 추가: } => "terminal", | |
| 99 | 추가: _ => "frame", | |
| 100 | 추가: }; | |
| 101 | 추가: self.observed.borrow_mut().jobs[self.index].push(label); | |
| 102 | 추가: Some(event) | |
| 103 | 추가: } | |
| 104 | 추가: } | |
| 105 | 추가: impl Drop for ObservedConnection { | |
| 106 | 추가: fn drop(&mut self) { | |
| 107 | 추가: self.observed.borrow_mut().jobs[self.index].push("drop"); | |
| 108 | 추가: } | |
| 109 | 추가: } | |
| 110 | 추가: fn observed_factory() -> (ObservedFactory, Rc<RefCell<Observation>>) { | |
| 111 | 추가: let observed = Rc::new(RefCell::new(Observation::default())); | |
| 112 | 추가: ( | |
| 113 | 추가: ObservedFactory { | |
| 114 | 추가: process: ProcessFactory::new(binary("zipelo-archive-worker")), | |
| 115 | 추가: observed: observed.clone(), | |
| 116 | 추가: }, | |
| 117 | 추가: observed, | |
| 118 | 추가: ) | |
| 119 | 추가: } | |
| 120 | 추가: fn assert_reaped(observed: &Rc<RefCell<Observation>>) { | |
| 121 | 추가: for events in &observed.borrow().jobs { | |
| 122 | 추가: for label in ["terminal", "stdout", "stderr", "cleanup", "wait", "drop"] { | |
| 123 | 추가: assert_eq!( | |
| 124 | 추가: events.iter().filter(|value| **value == label).count(), | |
| 125 | 추가: 1, | |
| 126 | 추가: "{events:?}" | |
| 127 | 추가: ); | |
| 128 | 추가: } | |
| 129 | 추가: assert!(!events.contains(&"fault")); | |
| 130 | 추가: assert_eq!(&events[events.len() - 2..], &["wait", "drop"]); | |
| 131 | 추가: } | |
| 132 | 추가: } | |
| 133 | 추가: fn wait(model: &mut Model) { | |
| 134 | 추가: let deadline = Instant::now() + Duration::from_secs(10); | |
| 135 | 추가: while model.busy() { | |
| 136 | 추가: model.poll(); | |
| 137 | 추가: assert!( | |
| 138 | 추가: Instant::now() < deadline, | |
| 139 | 추가: "작업자 종료 시간 초과: {}", | |
| 140 | 추가: model.status() | |
| 141 | 추가: ); | |
| 142 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 143 | 추가: } | |
| 144 | 추가: } | |
| 145 | 추가: fn completed(model: &Model) { | |
| 146 | 추가: assert!(model.confirmed, "{}", model.status()); | |
| 147 | 추가: assert_eq!(model.terminal.as_ref().unwrap().outcome, Outcome::Completed); | |
| 148 | 추가: } | |
| 149 | 추가: #[cfg(feature = "ui")] | |
| 150 | 추가: mod screen { | |
| 151 | 추가: use super::*; | |
| 152 | 추가: use eframe::egui::{self, epaint::Shape}; | |
| 153 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 154 | 추가: struct Screen { | |
| 155 | 추가: context: egui::Context, | |
| 156 | 추가: app: ArchiveApp, | |
| 157 | 추가: } | |
| 158 | 추가: impl Screen { | |
| 159 | 추가: fn new(factory: ObservedFactory) -> Self { | |
| 160 | 추가: Self { | |
| 161 | 추가: context: egui::Context::default(), | |
| 162 | 추가: app: ArchiveApp::new(Box::new(factory), None, false), | |
| 163 | 추가: } | |
| 164 | 추가: } | |
| 165 | 추가: fn render(&mut self, events: Vec<egui::Event>) -> Vec<(String, egui::Pos2)> { | |
| 166 | 추가: fn text(shape: &Shape, output: &mut Vec<(String, egui::Pos2)>) { | |
| 167 | 추가: match shape { | |
| 168 | 추가: Shape::Text(value) => output.push(( | |
| 169 | 추가: value.galley.job.text.clone(), | |
| 170 | 추가: value.pos + value.galley.rect.size() / 2.0, | |
| 171 | 추가: )), | |
| 172 | 추가: Shape::Vec(values) => { | |
| 173 | 추가: for value in values { | |
| 174 | 추가: text(value, output); | |
| 175 | 추가: } | |
| 176 | 추가: } | |
| 177 | 추가: _ => {} | |
| 178 | 추가: } | |
| 179 | 추가: } | |
| 180 | 추가: let mut frame = self.context.run_ui( | |
| 181 | 추가: egui::RawInput { | |
| 182 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 183 | 추가: egui::Pos2::ZERO, | |
| 184 | 추가: egui::vec2(1060.0, 720.0), | |
| 185 | 추가: )), | |
| 186 | 추가: events, | |
| 187 | 추가: ..Default::default() | |
| 188 | 추가: }, | |
| 189 | 추가: |ui| self.app.show(ui), | |
| 190 | 추가: ); | |
| 191 | 추가: frame.textures_delta.clear(); | |
| 192 | 추가: let mut output = Vec::new(); | |
| 193 | 추가: for shape in frame.shapes { | |
| 194 | 추가: text(&shape.shape, &mut output); | |
| 195 | 추가: } | |
| 196 | 추가: output | |
| 197 | 추가: } | |
| 198 | 추가: fn locate(&mut self, label: &str) -> egui::Pos2 { | |
| 199 | 추가: self.render(vec![]); | |
| 200 | 추가: self.render(vec![]) | |
| 201 | 추가: .into_iter() | |
| 202 | 추가: .filter(|(text, _)| text == label) | |
| 203 | 추가: .max_by(|a, b| a.1.y.total_cmp(&b.1.y)) | |
| 204 | 추가: .unwrap_or_else(|| panic!("화면 항목 누락: {label}")) | |
| 205 | 추가: .1 | |
| 206 | 추가: } | |
| 207 | 추가: fn click_at(&mut self, point: egui::Pos2) { | |
| 208 | 추가: self.render(vec![ | |
| 209 | 추가: egui::Event::PointerMoved(point), | |
| 210 | 추가: egui::Event::PointerButton { | |
| 211 | 추가: pos: point, | |
| 212 | 추가: button: egui::PointerButton::Primary, | |
| 213 | 추가: pressed: true, | |
| 214 | 추가: modifiers: Default::default(), | |
| 215 | 추가: }, | |
| 216 | 추가: ]); | |
| 217 | 추가: self.render(vec![egui::Event::PointerButton { | |
| 218 | 추가: pos: point, | |
| 219 | 추가: button: egui::PointerButton::Primary, | |
| 220 | 추가: pressed: false, | |
| 221 | 추가: modifiers: Default::default(), | |
| 222 | 추가: }]); | |
| 223 | 추가: } | |
| 224 | 추가: fn click(&mut self, label: &str) { | |
| 225 | 추가: let point = self.locate(label); | |
| 226 | 추가: self.click_at(point); | |
| 227 | 추가: } | |
| 228 | 추가: fn fill(&mut self, label: &str, offset: egui::Vec2, value: &Path) { | |
| 229 | 추가: let point = self.locate(label) + offset; | |
| 230 | 추가: self.click_at(point); | |
| 231 | 추가: self.render(vec![ | |
| 232 | 추가: egui::Event::Key { | |
| 233 | 추가: key: egui::Key::A, | |
| 234 | 추가: physical_key: None, | |
| 235 | 추가: pressed: true, | |
| 236 | 추가: repeat: false, | |
| 237 | 추가: modifiers: egui::Modifiers::COMMAND, | |
| 238 | 추가: }, | |
| 239 | 추가: egui::Event::Text(value.to_str().unwrap().to_string()), | |
| 240 | 추가: ]); | |
| 241 | 추가: } | |
| 242 | 추가: fn settle(&mut self) { | |
| 243 | 추가: let deadline = Instant::now() + Duration::from_secs(10); | |
| 244 | 추가: while self.app.model.busy() { | |
| 245 | 추가: self.render(vec![]); | |
| 246 | 추가: assert!(Instant::now() < deadline, "{}", self.app.model.status()); | |
| 247 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 248 | 추가: } | |
| 249 | 추가: completed(&self.app.model); | |
| 250 | 추가: } | |
| 251 | 추가: fn open(&mut self, archive: &Path) { | |
| 252 | 추가: self.click("파일 열기"); | |
| 253 | 추가: self.fill("압축파일 절대 경로", egui::vec2(0.0, 22.0), archive); | |
| 254 | 추가: self.click("열기"); | |
| 255 | 추가: assert!(self.app.model.busy()); | |
| 256 | 추가: self.settle(); | |
| 257 | 추가: } | |
| 258 | 추가: fn extract(&mut self, destination: &Path) { | |
| 259 | 추가: self.fill("출력 폴더", egui::vec2(100.0, 0.0), destination); | |
| 260 | 추가: self.click("풀기"); | |
| 261 | 추가: assert!(self.app.model.busy()); | |
| 262 | 추가: self.settle(); | |
| 263 | 추가: assert_eq!( | |
| 264 | 추가: self.app.model.terminal.as_ref().unwrap().publication, | |
| 265 | 추가: Publication::Complete | |
| 266 | 추가: ); | |
| 267 | 추가: } | |
| 268 | 추가: } | |
| 269 | 추가: fn archive_flow(name: &str, format: Format) { | |
| 270 | 추가: let scratch = Scratch::new(); | |
| 271 | 추가: let fixture = Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 272 | 추가: .join("../../tests/rust-app-real-worker/fixtures") | |
| 273 | 추가: .join(name); | |
| 274 | 추가: let archive = scratch.path(name); | |
| 275 | 추가: fs::copy(fixture, &archive).unwrap(); | |
| 276 | 추가: let original = fs::read(&archive).unwrap(); | |
| 277 | 추가: let output = make_directory(&scratch.path("output")); | |
| 278 | 추가: let (factory, observed) = observed_factory(); | |
| 279 | 추가: let mut screen = Screen::new(factory); | |
| 280 | 추가: screen.open(&archive); | |
| 281 | 추가: assert_eq!(screen.app.model.list_id.as_ref().unwrap().format, format); | |
| 282 | 추가: assert_eq!(screen.app.model.entries[0].name, "content.txt"); | |
| 283 | 추가: screen.extract(&output); | |
| 284 | 추가: assert_eq!( | |
| 285 | 추가: fs::read(output.join("content.txt")).unwrap(), | |
| 286 | 추가: b"Zipelo real worker flow\n" | |
| 287 | 추가: ); | |
| 288 | 추가: assert_eq!(fs::read(archive).unwrap(), original); | |
| 289 | 추가: assert_eq!(observed.borrow().jobs.len(), 2); | |
| 290 | 추가: assert_reaped(&observed); | |
| 291 | 추가: } | |
| 292 | 추가: #[test] | |
| 293 | 추가: fn seven_zip_open_and_extract_via_actual_widgets_and_worker() { | |
| 294 | 추가: for name in ["lzma.7z", "lzma2.7z"] { | |
| 295 | 추가: let scratch = Scratch::new(); | |
| 296 | 추가: let archive = scratch.path(name); | |
| 297 | 추가: fs::copy( | |
| 298 | 추가: Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 299 | 추가: .join("../../tests/rust-archive-worker/fixtures/7z") | |
| 300 | 추가: .join(name), | |
| 301 | 추가: &archive, | |
| 302 | 추가: ) | |
| 303 | 추가: .unwrap(); | |
| 304 | 추가: let original = fs::read(&archive).unwrap(); | |
| 305 | 추가: let output = make_directory(&scratch.path("output")); | |
| 306 | 추가: let (factory, observed) = observed_factory(); | |
| 307 | 추가: let mut screen = Screen::new(factory); | |
| 308 | 추가: screen.open(&archive); | |
| 309 | 추가: assert_eq!( | |
| 310 | 추가: screen.app.model.list_id.as_ref().unwrap().format, | |
| 311 | 추가: Format::SevenZip | |
| 312 | 추가: ); | |
| 313 | 추가: assert!(screen.app.model.can_extract()); | |
| 314 | 추가: screen.extract(&output); | |
| 315 | 추가: assert_eq!( | |
| 316 | 추가: fs::read(output.join("folder/hello.txt")).unwrap(), | |
| 317 | 추가: b"Zipelo 7z interoperability\n".repeat(100) | |
| 318 | 추가: ); | |
| 319 | 추가: assert_eq!(fs::read(archive).unwrap(), original); | |
| 320 | 추가: assert_eq!(observed.borrow().jobs.len(), 2); | |
| 321 | 추가: assert_reaped(&observed); | |
| 322 | 추가: } | |
| 323 | 추가: } | |
| 324 | 추가: #[test] | |
| 325 | 추가: fn zip_open_and_extract_via_actual_widgets_and_worker() { | |
| 326 | 추가: archive_flow("sample.zip", Format::Zip); | |
| 327 | 추가: } | |
| 328 | 추가: #[test] | |
| 329 | 추가: fn targz_open_and_extract_via_actual_widgets_and_worker() { | |
| 330 | 추가: archive_flow("sample.tar.gz", Format::TarGzip); | |
| 331 | 추가: } | |
| 332 | 추가: #[test] | |
| 333 | 추가: fn create_zip_reopen_and_extract_via_actual_widgets_and_worker() { | |
| 334 | 추가: let scratch = Scratch::new(); | |
| 335 | 추가: let source = scratch.path("one.txt"); | |
| 336 | 추가: fs::write(&source, b"ZIP creation through real worker\n").unwrap(); | |
| 337 | 추가: let archive = scratch.path("new.zip"); | |
| 338 | 추가: let output = make_directory(&scratch.path("output")); | |
| 339 | 추가: let (factory, observed) = observed_factory(); | |
| 340 | 추가: let mut screen = Screen::new(factory); | |
| 341 | 추가: screen.click("ZIP 만들기"); | |
| 342 | 추가: screen.fill( | |
| 343 | 추가: "원본 파일 절대 경로 / 한 줄에 하나", | |
| 344 | 추가: egui::vec2(0.0, 25.0), | |
| 345 | 추가: &source, | |
| 346 | 추가: ); | |
| 347 | 추가: screen.fill("저장할 ZIP 절대 경로", egui::vec2(0.0, 22.0), &archive); | |
| 348 | 추가: screen.click("ZIP 만들기"); | |
| 349 | 추가: assert!(screen.app.model.busy()); | |
| 350 | 추가: screen.settle(); | |
| 351 | 추가: assert!(archive.is_file()); | |
| 352 | 추가: screen.open(&archive); | |
| 353 | 추가: assert_eq!(screen.app.model.entries[0].name, "one.txt"); | |
| 354 | 추가: screen.extract(&output); | |
| 355 | 추가: assert_eq!( | |
| 356 | 추가: fs::read(output.join("one.txt")).unwrap(), | |
| 357 | 추가: fs::read(source).unwrap() | |
| 358 | 추가: ); | |
| 359 | 추가: assert_eq!(observed.borrow().jobs.len(), 3); | |
| 360 | 추가: assert_reaped(&observed); | |
| 361 | 추가: } | |
| 362 | 추가: } | |
| 363 | 추가: #[test] | |
| 364 | 추가: fn missing_worker_is_an_error_without_a_fake_result() { | |
| 365 | 추가: let scratch = Scratch::new(); | |
| 366 | 추가: let mut factory = ProcessFactory::new(scratch.path("not-installed")); | |
| 367 | 추가: let mut model = Model::default(); | |
| 368 | 추가: assert!(!model.begin( | |
| 369 | 추가: Start::List { | |
| 370 | 추가: archive: scratch.path("sample.zip") | |
| 371 | 추가: }, | |
| 372 | 추가: &mut factory | |
| 373 | 추가: )); | |
| 374 | 추가: assert!(!model.busy()); | |
| 375 | 추가: assert!(model.error.is_some()); | |
| 376 | 추가: assert!(!model.confirmed); | |
| 377 | 추가: } | |
| 378 | 추가: #[test] | |
| 379 | 추가: fn broken_or_incomplete_worker_output_is_not_success() { | |
| 380 | 추가: for name in ["truncated", "wrong-action", "early-exit"] { | |
| 381 | 추가: let scratch = Scratch::new(); | |
| 382 | 추가: let probe = scratch.path(&format!("{name}{}", std::env::consts::EXE_SUFFIX)); | |
| 383 | 추가: fs::copy(binary("zipelo-real-worker-probe"), &probe).unwrap(); | |
| 384 | 추가: let mut factory = ProcessFactory::new(probe); | |
| 385 | 추가: let mut model = Model::default(); | |
| 386 | 추가: assert!(model.begin( | |
| 387 | 추가: Start::List { | |
| 388 | 추가: archive: scratch.path("sample.zip") | |
| 389 | 추가: }, | |
| 390 | 추가: &mut factory | |
| 391 | 추가: )); | |
| 392 | 추가: model.request_close(); | |
| 393 | 추가: model.confirm_close(); | |
| 394 | 추가: assert_eq!(model.close, Close::Waiting); | |
| 395 | 추가: wait(&mut model); | |
| 396 | 추가: assert!(!model.confirmed); | |
| 397 | 추가: assert!(model.error.is_some()); | |
| 398 | 추가: assert_eq!(model.close, Close::Review); | |
| 399 | 추가: model.acknowledge_close(); | |
| 400 | 추가: assert_eq!(model.close, Close::Allowed); | |
| 401 | 추가: } | |
| 402 | 추가: } | |
| 403 | 추가: #[cfg(target_os = "linux")] | |
| 404 | 추가: #[test] | |
| 405 | 추가: fn dropping_live_connection_kills_and_reaps_owned_child() { | |
| 406 | 추가: let scratch = Scratch::new(); | |
| 407 | 추가: let probe = scratch.path("hang"); | |
| 408 | 추가: fs::copy(binary("zipelo-real-worker-probe"), &probe).unwrap(); | |
| 409 | 추가: let mut factory = ProcessFactory::new(probe); | |
| 410 | 추가: let mut model = Model::default(); | |
| 411 | 추가: assert!(model.begin( | |
| 412 | 추가: Start::List { | |
| 413 | 추가: archive: scratch.path("sample.zip") | |
| 414 | 추가: }, | |
| 415 | 추가: &mut factory | |
| 416 | 추가: )); | |
| 417 | 추가: let deadline = Instant::now() + Duration::from_secs(5); | |
| 418 | 추가: while !scratch.path("probe.pid").exists() { | |
| 419 | 추가: assert!(Instant::now() < deadline); | |
| 420 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 421 | 추가: } | |
| 422 | 추가: let pid = fs::read_to_string(scratch.path("probe.pid")).unwrap(); | |
| 423 | 추가: drop(model); | |
| 424 | 추가: assert!(!Path::new("/proc").join(pid).exists()); | |
| 425 | 추가: } | |
| 426 | 추가: | |
| 427 | 추가: #[test] | |
| 428 | 추가: fn failed_start_serialization_reaps_the_real_worker_without_terminal() { | |
| 429 | 추가: let scratch = Scratch::new(); | |
| 430 | 추가: let mut factory = ProcessFactory::new(binary("zipelo-archive-worker")); | |
| 431 | 추가: let mut model = Model::default(); | |
| 432 | 추가: let archive = scratch.path(&"a".repeat(40000)); | |
| 433 | 추가: assert!(!model.begin(Start::List { archive }, &mut factory)); | |
| 434 | 추가: assert!(model.busy()); | |
| 435 | 추가: model.request_close(); | |
| 436 | 추가: model.confirm_close(); | |
| 437 | 추가: assert_eq!(model.close, Close::Waiting); | |
| 438 | 추가: wait(&mut model); | |
| 439 | 추가: assert!(!model.confirmed); | |
| 440 | 추가: assert!(model.terminal.is_none()); | |
| 441 | 추가: assert!(model.error.is_some()); | |
| 442 | 추가: assert_eq!(model.close, Close::Review); | |
| 443 | 추가: } | |
| 444 | 추가: | |
| 445 | 추가: #[test] | |
| 446 | 추가: fn late_cancel_after_child_reap_keeps_the_original_terminal_result() { | |
| 447 | 추가: let scratch = Scratch::new(); | |
| 448 | 추가: let archive = scratch.path("sample.zip"); | |
| 449 | 추가: fs::copy( | |
| 450 | 추가: Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 451 | 추가: .join("../../tests/rust-app-real-worker/fixtures/sample.zip"), | |
| 452 | 추가: &archive, | |
| 453 | 추가: ) | |
| 454 | 추가: .unwrap(); | |
| 455 | 추가: let mut factory = ProcessFactory::new(binary("zipelo-archive-worker")); | |
| 456 | 추가: let mut connection = factory.connect(1).unwrap(); | |
| 457 | 추가: connection | |
| 458 | 추가: .send(Request { | |
| 459 | 추가: job_id: 1, | |
| 460 | 추가: sequence: 0, | |
| 461 | 추가: command: Command::Start(Start::List { archive }), | |
| 462 | 추가: }) | |
| 463 | 추가: .unwrap(); | |
| 464 | 추가: let deadline = Instant::now() + Duration::from_secs(10); | |
| 465 | 추가: let mut terminal = false; | |
| 466 | 추가: loop { | |
| 467 | 추가: assert!(Instant::now() < deadline); | |
| 468 | 추가: match connection.poll() { | |
| 469 | 추가: Some(HostEvent::CleanupComplete) => break, | |
| 470 | 추가: Some(HostEvent::Frame { | |
| 471 | 추가: event: Event::Terminal(value), | |
| 472 | 추가: .. | |
| 473 | 추가: }) => { | |
| 474 | 추가: assert_eq!(value.outcome, Outcome::Completed); | |
| 475 | 추가: terminal = true; | |
| 476 | 추가: } | |
| 477 | 추가: Some(HostEvent::Fault(message)) => panic!("{message}"), | |
| 478 | 추가: _ => std::thread::sleep(Duration::from_millis(1)), | |
| 479 | 추가: } | |
| 480 | 추가: } | |
| 481 | 추가: assert!(terminal); | |
| 482 | 추가: assert!( | |
| 483 | 추가: connection | |
| 484 | 추가: .send(Request { | |
| 485 | 추가: job_id: 1, | |
| 486 | 추가: sequence: 1, | |
| 487 | 추가: command: Command::Cancel | |
| 488 | 추가: }) | |
| 489 | 추가: .is_ok() | |
| 490 | 추가: ); | |
| 491 | 추가: loop { | |
| 492 | 추가: assert!(Instant::now() < deadline); | |
| 493 | 추가: match connection.poll() { | |
| 494 | 추가: Some(HostEvent::Exited { success }) => { | |
| 495 | 추가: assert!(success); | |
| 496 | 추가: break; | |
| 497 | 추가: } | |
| 498 | 추가: Some(HostEvent::Fault(message)) => panic!("{message}"), | |
| 499 | 추가: _ => std::thread::sleep(Duration::from_millis(1)), | |
| 500 | 추가: } | |
| 501 | 추가: } | |
| 502 | 추가: assert!(connection.poll().is_none()); | |
| 503 | 추가: } | |
| 504 | 추가: | |
| 505 | 추가: #[test] | |
| 506 | 추가: fn cancel_racing_child_exit_preserves_completed_result_before_poll() { | |
| 507 | 추가: let archive = Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 508 | 추가: .join("../../tests/rust-app-real-worker/fixtures/sample.zip") | |
| 509 | 추가: .canonicalize() | |
| 510 | 추가: .unwrap(); | |
| 511 | 추가: for iteration in 0..100 { | |
| 512 | 추가: let mut factory = ProcessFactory::new(binary("zipelo-archive-worker")); | |
| 513 | 추가: let mut model = Model::default(); | |
| 514 | 추가: assert!(model.begin( | |
| 515 | 추가: Start::List { | |
| 516 | 추가: archive: archive.clone() | |
| 517 | 추가: }, | |
| 518 | 추가: &mut factory | |
| 519 | 추가: )); | |
| 520 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 521 | 추가: model.cancel(); | |
| 522 | 추가: wait(&mut model); | |
| 523 | 추가: assert!(model.confirmed, "iteration={iteration}: {:?}", model.error); | |
| 524 | 추가: assert_eq!(model.terminal.as_ref().unwrap().outcome, Outcome::Completed); | |
| 525 | 추가: assert!(model.error.is_none()); | |
| 526 | 추가: } | |
| 527 | 추가: } | |
| 528 | 추가: | |
| 529 | 추가: #[test] | |
| 530 | 추가: fn cancel_racing_exit_without_terminal_remains_unconfirmed() { | |
| 531 | 추가: let scratch = Scratch::new(); | |
| 532 | 추가: let probe = scratch.path("early-exit"); | |
| 533 | 추가: fs::copy(binary("zipelo-real-worker-probe"), &probe).unwrap(); | |
| 534 | 추가: let mut factory = ProcessFactory::new(probe); | |
| 535 | 추가: let mut model = Model::default(); | |
| 536 | 추가: assert!(model.begin( | |
| 537 | 추가: Start::List { | |
| 538 | 추가: archive: scratch.path("sample.zip") | |
| 539 | 추가: }, | |
| 540 | 추가: &mut factory | |
| 541 | 추가: )); | |
| 542 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 543 | 추가: model.cancel(); | |
| 544 | 추가: model.request_close(); | |
| 545 | 추가: model.confirm_close(); | |
| 546 | 추가: assert_eq!(model.close, Close::Waiting); | |
| 547 | 추가: wait(&mut model); | |
| 548 | 추가: assert!(!model.confirmed); | |
| 549 | 추가: assert!(model.terminal.is_none()); | |
| 550 | 추가: assert!(model.error.is_some()); | |
| 551 | 추가: assert_eq!(model.close, Close::Review); | |
| 552 | 추가: } |
| @@ -0,0 +1,130 @@ | ||
| 1 | 추가: #![allow(dead_code)] | |
| 2 | 추가: #[path = "../../experiments/rust-ui-memory-app/src/archive_ui.rs"] | |
| 3 | 추가: mod archive_ui; | |
| 4 | 추가: mod adapter { | |
| 5 | 추가: include!("../../experiments/rust-ui-memory-app/src/archive_process.rs"); | |
| 6 | 추가: | |
| 7 | 추가: fn token(format: ui::Format, source_object: ui::SourceObject) -> ui::ListId { | |
| 8 | 추가: ui::ListId { | |
| 9 | 추가: catalog_version: 1, | |
| 10 | 추가: format, | |
| 11 | 추가: source_object, | |
| 12 | 추가: archive_bytes: 33, | |
| 13 | 추가: archive_sha256: [44; 32], | |
| 14 | 추가: } | |
| 15 | 추가: } | |
| 16 | 추가: fn formats() -> [ui::Format; 5] { | |
| 17 | 추가: [ | |
| 18 | 추가: ui::Format::Zip, | |
| 19 | 추가: ui::Format::Tar, | |
| 20 | 추가: ui::Format::Gzip, | |
| 21 | 추가: ui::Format::TarGzip, | |
| 22 | 추가: ui::Format::SevenZip, | |
| 23 | 추가: ] | |
| 24 | 추가: } | |
| 25 | 추가: #[test] | |
| 26 | 추가: fn list_end_preserves_existing_tags_and_assigns_four_to_seven_zip() { | |
| 27 | 추가: for (tag, format) in formats().into_iter().enumerate() { | |
| 28 | 추가: let id = token( | |
| 29 | 추가: format, | |
| 30 | 추가: ui::SourceObject::Unix { | |
| 31 | 추가: device: 11, | |
| 32 | 추가: inode: 22, | |
| 33 | 추가: }, | |
| 34 | 추가: ); | |
| 35 | 추가: let mut actual = Vec::new(); | |
| 36 | 추가: codec::Writer::new(&mut actual, 99) | |
| 37 | 추가: .send(&wire::Message::ListEnd { | |
| 38 | 추가: entry_count: 7, | |
| 39 | 추가: list_id: list_to_wire(id.clone()), | |
| 40 | 추가: }) | |
| 41 | 추가: .unwrap(); | |
| 42 | 추가: let mut body = Vec::new(); | |
| 43 | 추가: body.extend(7u32.to_le_bytes()); | |
| 44 | 추가: body.extend(1u16.to_le_bytes()); | |
| 45 | 추가: body.push(tag as u8); | |
| 46 | 추가: body.push(1); | |
| 47 | 추가: body.extend(11u64.to_le_bytes()); | |
| 48 | 추가: body.extend(22u64.to_le_bytes()); | |
| 49 | 추가: body.extend(33u64.to_le_bytes()); | |
| 50 | 추가: body.extend([44; 32]); | |
| 51 | 추가: let mut expected = Vec::from(*b"ZAW1"); | |
| 52 | 추가: expected.extend(1u16.to_le_bytes()); | |
| 53 | 추가: expected.extend(102u16.to_le_bytes()); | |
| 54 | 추가: expected.extend((body.len() as u32).to_le_bytes()); | |
| 55 | 추가: expected.extend([0; 4]); | |
| 56 | 추가: expected.extend(99u64.to_le_bytes()); | |
| 57 | 추가: expected.extend(0u64.to_le_bytes()); | |
| 58 | 추가: expected.extend(body); | |
| 59 | 추가: assert_eq!(actual, expected); | |
| 60 | 추가: let (_, _, message) = codec::Reader::new(actual.as_slice()) | |
| 61 | 추가: .read() | |
| 62 | 추가: .unwrap() | |
| 63 | 추가: .unwrap(); | |
| 64 | 추가: match event_to_ui(message, None).unwrap() { | |
| 65 | 추가: ui::Event::ListEnd { | |
| 66 | 추가: entry_count, | |
| 67 | 추가: list_id, | |
| 68 | 추가: } => { | |
| 69 | 추가: assert_eq!(entry_count, 7); | |
| 70 | 추가: assert_eq!(list_id, id); | |
| 71 | 추가: } | |
| 72 | 추가: _ => panic!("목록 완료 응답이 아님"), | |
| 73 | 추가: } | |
| 74 | 추가: } | |
| 75 | 추가: } | |
| 76 | 추가: #[test] | |
| 77 | 추가: fn extraction_roundtrip_preserves_both_platform_identities_and_all_formats() { | |
| 78 | 추가: for source in [ | |
| 79 | 추가: ui::SourceObject::Unix { | |
| 80 | 추가: device: 11, | |
| 81 | 추가: inode: 22, | |
| 82 | 추가: }, | |
| 83 | 추가: ui::SourceObject::Windows { | |
| 84 | 추가: volume: 55, | |
| 85 | 추가: file_id: [66; 16], | |
| 86 | 추가: }, | |
| 87 | 추가: ] { | |
| 88 | 추가: for format in formats() { | |
| 89 | 추가: let id = token(format, source.clone()); | |
| 90 | 추가: assert_eq!(list_to_ui(list_to_wire(id.clone())), id); | |
| 91 | 추가: let start = start_to_wire(ui::Start::Extract { | |
| 92 | 추가: archive: PathBuf::from("input.7z"), | |
| 93 | 추가: destination: PathBuf::from("output"), | |
| 94 | 추가: selection: ui::Selection::EntryIds(vec![7]), | |
| 95 | 추가: list_id: id.clone(), | |
| 96 | 추가: gzip_output_name: if format == ui::Format::Gzip { | |
| 97 | 추가: Some("content".into()) | |
| 98 | 추가: } else { | |
| 99 | 추가: None | |
| 100 | 추가: }, | |
| 101 | 추가: }); | |
| 102 | 추가: let mut bytes = Vec::new(); | |
| 103 | 추가: codec::Writer::new(&mut bytes, 99) | |
| 104 | 추가: .send(&wire::Message::Start(start)) | |
| 105 | 추가: .unwrap(); | |
| 106 | 추가: assert_eq!(&bytes[6..8], &1u16.to_le_bytes()); | |
| 107 | 추가: match codec::Reader::new(bytes.as_slice()) | |
| 108 | 추가: .read() | |
| 109 | 추가: .unwrap() | |
| 110 | 추가: .unwrap() | |
| 111 | 추가: .2 | |
| 112 | 추가: { | |
| 113 | 추가: wire::Message::Start(wire::Start { | |
| 114 | 추가: action: | |
| 115 | 추가: wire::Action::Extract { | |
| 116 | 추가: list_id: Some(decoded), | |
| 117 | 추가: selection, | |
| 118 | 추가: .. | |
| 119 | 추가: }, | |
| 120 | 추가: .. | |
| 121 | 추가: }) => { | |
| 122 | 추가: assert_eq!(list_to_ui(decoded), id); | |
| 123 | 추가: assert_eq!(selection, wire::Selection::EntryIds(vec![7])); | |
| 124 | 추가: } | |
| 125 | 추가: _ => panic!("압축 해제 요청이 아님"), | |
| 126 | 추가: } | |
| 127 | 추가: } | |
| 128 | 추가: } | |
| 129 | 추가: } | |
| 130 | 추가: } |
| @@ -0,0 +1,24 @@ | ||
| 1 | 추가: import gzip | |
| 2 | 추가: from io import BytesIO | |
| 3 | 추가: from pathlib import Path | |
| 4 | 추가: import tarfile | |
| 5 | 추가: import zipfile | |
| 6 | 추가: | |
| 7 | 추가: ROOT = Path(__file__).resolve().parent / "fixtures" | |
| 8 | 추가: PAYLOAD = b"Zipelo real worker flow\n" | |
| 9 | 추가: ROOT.mkdir(exist_ok=True) | |
| 10 | 추가: stream = BytesIO() | |
| 11 | 추가: with zipfile.ZipFile(stream, "w") as archive: | |
| 12 | 추가: info = zipfile.ZipInfo("content.txt", (1980, 1, 1, 0, 0, 0)) | |
| 13 | 추가: info.compress_type = zipfile.ZIP_DEFLATED | |
| 14 | 추가: archive.writestr(info, PAYLOAD) | |
| 15 | 추가: (ROOT / "sample.zip").write_bytes(stream.getvalue()) | |
| 16 | 추가: stream = BytesIO() | |
| 17 | 추가: with tarfile.open(fileobj=stream, mode="w", format=tarfile.USTAR_FORMAT) as archive: | |
| 18 | 추가: info = tarfile.TarInfo("content.txt") | |
| 19 | 추가: info.size = len(PAYLOAD) | |
| 20 | 추가: info.mode = 0o600 | |
| 21 | 추가: archive.addfile(info, BytesIO(PAYLOAD)) | |
| 22 | 추가: compressed = bytearray(gzip.compress(stream.getvalue(), mtime=0)) | |
| 23 | 추가: compressed[9] = 255 | |
| 24 | 추가: (ROOT / "sample.tar.gz").write_bytes(compressed) |
| @@ -0,0 +1,29 @@ | ||
| 1 | 추가: use std::{io::Write, path::PathBuf, time::Duration}; | |
| 2 | 추가: use worker_protocol::{ | |
| 3 | 추가: protocol::*, | |
| 4 | 추가: wire::{Reader, Writer}, | |
| 5 | 추가: }; | |
| 6 | 추가: | |
| 7 | 추가: fn main() { | |
| 8 | 추가: let executable = PathBuf::from(std::env::args_os().next().unwrap()); | |
| 9 | 추가: let mode = executable.file_stem().unwrap().to_string_lossy(); | |
| 10 | 추가: if mode.starts_with("hang") { | |
| 11 | 추가: let parent = executable.parent().unwrap(); | |
| 12 | 추가: std::fs::write(parent.join("probe.pid.tmp"), std::process::id().to_string()).unwrap(); | |
| 13 | 추가: std::fs::rename(parent.join("probe.pid.tmp"), parent.join("probe.pid")).unwrap(); | |
| 14 | 추가: std::thread::sleep(Duration::from_secs(30)); | |
| 15 | 추가: return; | |
| 16 | 추가: } | |
| 17 | 추가: let mut reader = Reader::new(std::io::stdin()); | |
| 18 | 추가: let (job, _, _) = reader.read().unwrap().unwrap(); | |
| 19 | 추가: if mode.starts_with("wrong-action") { | |
| 20 | 추가: Writer::new(std::io::stdout(), job) | |
| 21 | 추가: .send(&Message::Accepted { | |
| 22 | 추가: action: ActionKind::Extract, | |
| 23 | 추가: encryption: false, | |
| 24 | 추가: }) | |
| 25 | 추가: .unwrap(); | |
| 26 | 추가: } else if !mode.starts_with("early-exit") { | |
| 27 | 추가: std::io::stdout().write_all(b"ZAW1").unwrap(); | |
| 28 | 추가: } | |
| 29 | 추가: } |
| @@ -10,7 +10,7 @@ | ||
| 10 | 10 | cargo +1.99.1 run --locked --manifest-path experiments/rust-ui-memory-app/Cargo.toml --features ui-fixture -- --ui-fixture /absolute/example.zip |
| 11 | 11 | ``` |
| 12 | 12 | |
| 13 | 삭제: `locked.zip` 이름은 가짜 암호 요청을 만듦. 아무 비어 있지 않은 합성 암호를 받으며 암호를 기록하거나 저장하지 않음. 실제 암호나 사용자 자료를 입력할 필요가 없음. 시험 모드는 화면에 명시되고 실제 파일을 만들지 않음. `ui-fixture` 없이 실행하면 작업자 미연결 오류를 표시하며 가짜 성공으로 대체하지 않음. | |
| 13 | 추가: `locked.zip` 이름은 가짜 암호 요청을 만듦. 아무 비어 있지 않은 합성 암호를 받으며 암호를 기록하거나 저장하지 않음. 실제 암호나 사용자 자료를 입력할 필요가 없음. 시험 모드는 화면에 명시되고 실제 파일을 만들지 않음. `ui-fixture` 없이 실행하면 앱과 같은 폴더의 실제 zipelo-archive-worker를 실행함. Windows에서는 .exe 확장자를 사용함. 작업자가 누락되면 오류를 표시하며 가짜 성공으로 대체하지 않음. 실제 작업자 연결 시험은 ../rust-app-real-worker/README.md를 참고할 것. | |
| 14 | 14 | |
| 15 | 15 | 범위는 목록 확인, 선택 해제, GZ 출력명, ZIP 생성, 암호 요청, 진행률, 취소와 닫기 철회, Terminal/EOF/child wait 분리, 오래된 ID/sequence 거부, SourceChanged 재열람, 부분 출력과 불확실 게시 보존임. 구성한 이벤트 시험은 실제 OS 종료나 파일 보안 검증의 증거가 아님. |
| 16 | 16 |
| @@ -726,3 +726,84 @@ fn fake_worker_rejects_invalid_format_specific_output_names() { | ||
| 726 | 726 | assert_eq!(factory.state.borrow().starts.len(), previous); |
| 727 | 727 | } |
| 728 | 728 | } |
| 729 | 추가: | |
| 730 | 추가: #[test] | |
| 731 | 추가: fn cleanup_marker_without_error_does_not_replace_eofs() { | |
| 732 | 추가: let mut factory = FakeFactory::manual(); | |
| 733 | 추가: let mut model = Model::default(); | |
| 734 | 추가: assert!(model.begin( | |
| 735 | 추가: Start::List { | |
| 736 | 추가: archive: path("sample.zip") | |
| 737 | 추가: }, | |
| 738 | 추가: &mut factory | |
| 739 | 추가: )); | |
| 740 | 추가: factory | |
| 741 | 추가: .state | |
| 742 | 추가: .borrow_mut() | |
| 743 | 추가: .queue | |
| 744 | 추가: .push_back(HostEvent::CleanupComplete); | |
| 745 | 추가: factory | |
| 746 | 추가: .state | |
| 747 | 추가: .borrow_mut() | |
| 748 | 추가: .queue | |
| 749 | 추가: .push_back(HostEvent::Exited { success: true }); | |
| 750 | 추가: for _ in 0..10 { | |
| 751 | 추가: model.poll(); | |
| 752 | 추가: } | |
| 753 | 추가: assert!(model.busy()); | |
| 754 | 추가: factory | |
| 755 | 추가: .state | |
| 756 | 추가: .borrow_mut() | |
| 757 | 추가: .queue | |
| 758 | 추가: .push_back(HostEvent::StdoutEof); | |
| 759 | 추가: for _ in 0..10 { | |
| 760 | 추가: model.poll(); | |
| 761 | 추가: } | |
| 762 | 추가: assert!(model.busy()); | |
| 763 | 추가: factory | |
| 764 | 추가: .state | |
| 765 | 추가: .borrow_mut() | |
| 766 | 추가: .queue | |
| 767 | 추가: .push_back(HostEvent::StderrEof); | |
| 768 | 추가: pump(&mut model); | |
| 769 | 추가: assert!(!model.confirmed); | |
| 770 | 추가: } | |
| 771 | 추가: | |
| 772 | 추가: #[test] | |
| 773 | 추가: fn error_cleanup_requires_child_wait_without_fabricating_terminal() { | |
| 774 | 추가: let mut factory = FakeFactory::manual(); | |
| 775 | 추가: let mut model = Model::default(); | |
| 776 | 추가: assert!(model.begin( | |
| 777 | 추가: Start::List { | |
| 778 | 추가: archive: path("sample.zip") | |
| 779 | 추가: }, | |
| 780 | 추가: &mut factory | |
| 781 | 추가: )); | |
| 782 | 추가: factory | |
| 783 | 추가: .state | |
| 784 | 추가: .borrow_mut() | |
| 785 | 추가: .queue | |
| 786 | 추가: .push_back(HostEvent::Fault("pipe error".into())); | |
| 787 | 추가: factory | |
| 788 | 추가: .state | |
| 789 | 추가: .borrow_mut() | |
| 790 | 추가: .queue | |
| 791 | 추가: .push_back(HostEvent::CleanupComplete); | |
| 792 | 추가: model.request_close(); | |
| 793 | 추가: model.confirm_close(); | |
| 794 | 추가: for _ in 0..10 { | |
| 795 | 추가: model.poll(); | |
| 796 | 추가: } | |
| 797 | 추가: assert!(model.busy()); | |
| 798 | 추가: assert_eq!(model.close, Close::Waiting); | |
| 799 | 추가: factory | |
| 800 | 추가: .state | |
| 801 | 추가: .borrow_mut() | |
| 802 | 추가: .queue | |
| 803 | 추가: .push_back(HostEvent::Exited { success: false }); | |
| 804 | 추가: pump(&mut model); | |
| 805 | 추가: assert!(!model.confirmed); | |
| 806 | 추가: assert!(model.terminal.is_none()); | |
| 807 | 추가: assert_eq!(model.error.as_deref(), Some("pipe error")); | |
| 808 | 추가: assert_eq!(model.close, Close::Review); | |
| 809 | 추가: } |
| @@ -1,47 +1,92 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "command": "python3 tests/ci/run_rust.py local", |
| 3 | 3 | "platform": "linux-desktop-2", |
| 4 | 삭제: "base_remote_main": "486fe9ae64a73f999cc5122c2eb9bbeb62fb2fb3", | |
| 5 | 삭제: "local_baseline_head": "6ea0b8b3b7444c35bb0845b58bf5638ac58f5e58", | |
| 6 | 삭제: "source_state": "Committed frontend review fixes over the existing local baseline whose tree equals remote main. Tested file hashes identify the reviewed implementation.", | |
| 7 | 삭제: "linux_build_crates": 17, | |
| 8 | 삭제: "linux_test_targets": 17, | |
| 9 | 삭제: "rust_tests_passed": 827, | |
| 10 | 삭제: "new_archive_ui_tests_passed": 20, | |
| 11 | 삭제: "windows_cross_build_crates": 17, | |
| 4 | 추가: "base_remote_main": "3f51510fcc613c3f72e29c3b421aab178bf94186", | |
| 5 | 추가: "local_baseline_head": "c2fba601990de3b0ad660342fdd9762e35b35147", | |
| 6 | 추가: "source_state": "Tested committed integration source. Only this evidence JSON was updated after the full runner completed; hashes identify the tested code and fixtures.", | |
| 7 | 추가: "linux_build_crates": 19, | |
| 8 | 추가: "linux_test_targets": 19, | |
| 9 | 추가: "rust_tests_passed": 883, | |
| 10 | 추가: "new_archive_ui_tests_passed": 22, | |
| 11 | 추가: "windows_cross_build_crates": 19, | |
| 12 | 12 | "windows_runtime_tested": false, |
| 13 | 삭제: "native_visual_check": "Owned Xvfb screen displayed Korean synthetic file list; initial capture missed Xvfb because inherited Wayland selected host backend; corrected capture removes Wayland only in owned process environment. Not complete native interaction coverage.", | |
| 13 | 추가: "native_visual_check": "Headless egui Context used actual widget pointer/key events and the real OS worker process on Linux. Native OS window/input automation and Windows execution were not performed.", | |
| 14 | 14 | "prior_failures": "Retained locally: first build drop API/legacy harness references; second and third egui renderer harness texture/first-frame setup; final runner passed.", |
| 15 | 15 | "limitations": [ |
| 16 | 삭제: "Fake transport projects agreed revision2 semantics; no binary codec, actual worker process, filesystem extraction or encryption in this frontend PR.", | |
| 17 | 삭제: "Default executable explicitly reports unavailable worker. ui-fixture feature AND --ui-fixture flag select test-only fake; UI labels it.", | |
| 18 | 삭제: "Entry listing is metadata, not integrity proof. Partial publication/durability/cleanup remain separate.", | |
| 19 | 삭제: "UTF-8 text fields for manual paths; native CLI/drop archive paths stay PathBuf. ZIP multi-source manual entry is UTF-8 only." | |
| 16 | 추가: "Normal ZIP/TAR.GZ/7z listing and extraction plus ZIP creation/reopen/extraction use the actual worker executable and OS pipes.", | |
| 17 | 추가: "Four successful screen tests run headless egui widgets, including LZMA/LZMA2 7z fixtures, not native OS GUI automation.", | |
| 18 | 추가: "Malformed, wrong-action, early-exit and disposal fault cases use a separate test-only probe; serialization failure and late cancellation use the actual worker.", | |
| 19 | 추가: "No Windows runtime, encryption ZIP, large-file performance, OS sandbox or exhaustive malicious-input validation in this frontend integration.", | |
| 20 | 추가: "Manual path text is UTF-8; native archive CLI/drop paths retain PathBuf and NativePath." | |
| 20 | 21 | ], |
| 21 | 22 | "tested_files": [ |
| 23 | 추가: { | |
| 24 | 추가: "path": "experiments/rust-ui-memory-app/Cargo.lock", | |
| 25 | 추가: "sha256": "791935d3b7eb17f68ccd08e35e6839e3ff42fecf9fd51cce4ce69fb7bb717197" | |
| 26 | 추가: }, | |
| 22 | 27 | { |
| 23 | 28 | "path": "experiments/rust-ui-memory-app/Cargo.toml", |
| 24 | 삭제: "sha256": "1b161c74260b64de926b37528d61fd73de4074d250f711d8458ed770c0af69d8" | |
| 29 | 추가: "sha256": "d2ba4202c0920af4b090fb59245f92b59c14f0590930ca4c6d8874d77057a577" | |
| 25 | 30 | }, |
| 26 | 31 | { |
| 27 | 삭제: "path": "experiments/rust-ui-memory-app/src/lib.rs", | |
| 28 | 삭제: "sha256": "335104e14b4fd69fd20e29941a1cc40c7c123bd7b853c09206c39d10b55fda2c" | |
| 32 | 추가: "path": "experiments/rust-ui-memory-app/src/archive_process.rs", | |
| 33 | 추가: "sha256": "a75457134618ba7c8b0e8ee7800e14ec5c77fadac5c62fdac2ccf1fa663bd142" | |
| 29 | 34 | }, |
| 30 | 35 | { |
| 31 | 삭제: "path": "experiments/rust-ui-memory-app/src/desktop.rs", | |
| 32 | 삭제: "sha256": "5d0e14f72cdebc6fe02952539db55c682cb5978fd883e072bd08d461807c8106" | |
| 36 | 추가: "path": "experiments/rust-ui-memory-app/src/archive_screen.rs", | |
| 37 | 추가: "sha256": "04b7a55c7405d89467fc821db27e0714fb0aa00612e614835b5fee901e5ca940" | |
| 33 | 38 | }, |
| 34 | 39 | { |
| 35 | 40 | "path": "experiments/rust-ui-memory-app/src/archive_ui.rs", |
| 36 | 삭제: "sha256": "f06fd50c557e178cb5cb98cb39e3ba5e04088a774f60ec92774bc37ed3323b87" | |
| 41 | 추가: "sha256": "f26557645cea07350843c7e88225e07bb4316ab673dc2581b036567f01d66d6e" | |
| 37 | 42 | }, |
| 38 | 43 | { |
| 39 | 삭제: "path": "experiments/rust-ui-memory-app/src/archive_screen.rs", | |
| 40 | 삭제: "sha256": "04b7a55c7405d89467fc821db27e0714fb0aa00612e614835b5fee901e5ca940" | |
| 44 | 추가: "path": "experiments/rust-ui-memory-app/src/desktop.rs", | |
| 45 | 추가: "sha256": "c829ec00ae84a8b695af65edb2665c0308e2af14cf26c4a2736364452a99795c" | |
| 41 | 46 | }, |
| 42 | 47 | { |
| 43 | 삭제: "path": "tests/rust-app-ui/regressions.rs", | |
| 44 | 삭제: "sha256": "461e9a36bc5b742bf523fe0f1bfb7900c1b97a884e3e8f6040f85fe474efdf4e" | |
| 48 | 추가: "path": "experiments/rust-ui-memory-app/src/lib.rs", | |
| 49 | 추가: "sha256": "bf7d61f41973d3811b868959786a74873bcd320a36445f9cb1e6034813add7df" | |
| 50 | 추가: }, | |
| 51 | 추가: { | |
| 52 | 추가: "path": "tests/rust-app-real-worker/.gitignore", | |
| 53 | 추가: "sha256": "247681cefffa8448d973f21147c92b38b63f492a98a50aca3b3c490bc97499e1" | |
| 54 | 추가: }, | |
| 55 | 추가: { | |
| 56 | 추가: "path": "tests/rust-app-real-worker/Cargo.lock", | |
| 57 | 추가: "sha256": "6fce2f154d57e28e975582755ca13d9ebb4d2d6927a53c42f03e8a9b5f78f78c" | |
| 58 | 추가: }, | |
| 59 | 추가: { | |
| 60 | 추가: "path": "tests/rust-app-real-worker/Cargo.toml", | |
| 61 | 추가: "sha256": "2247dcbfa35d791f95ab0cbd509646da3af1744ba0066ada98366f10cab3e2fa" | |
| 62 | 추가: }, | |
| 63 | 추가: { | |
| 64 | 추가: "path": "tests/rust-app-real-worker/README.md", | |
| 65 | 추가: "sha256": "7253cd2a765dc594e3a27970fd3811eb50645d1179c2728b57eee2d440b3e367" | |
| 66 | 추가: }, | |
| 67 | 추가: { | |
| 68 | 추가: "path": "tests/rust-app-real-worker/fixtures/sample.tar.gz", | |
| 69 | 추가: "sha256": "5589f9bec624071d0d90b595d0283da82c1516fced9a13246a9bb9e7e951e372" | |
| 70 | 추가: }, | |
| 71 | 추가: { | |
| 72 | 추가: "path": "tests/rust-app-real-worker/fixtures/sample.zip", | |
| 73 | 추가: "sha256": "21e6ac2989f40ac485b2eb5e9f2a5adc7c8aeb7feabbd55a74f0cdc33f71cc3d" | |
| 74 | 추가: }, | |
| 75 | 추가: { | |
| 76 | 추가: "path": "tests/rust-app-real-worker/flows.rs", | |
| 77 | 추가: "sha256": "a6ae9c4c56860f572667465c657c2167e619d5892469d986d6c8615ee9c2ae6d" | |
| 78 | 추가: }, | |
| 79 | 추가: { | |
| 80 | 추가: "path": "tests/rust-app-real-worker/generate.py", | |
| 81 | 추가: "sha256": "480f5503ee0aa537f24506964c07ae84a7696cc8ffdb6ba8907b2912913bb6ce" | |
| 82 | 추가: }, | |
| 83 | 추가: { | |
| 84 | 추가: "path": "tests/rust-app-real-worker/probe.rs", | |
| 85 | 추가: "sha256": "cf8eadd227d507469ecf71ece9f02efb95a208d677f107cf03fd107f67e1bd56" | |
| 86 | 추가: }, | |
| 87 | 추가: { | |
| 88 | 추가: "path": "tests/rust-app-ui/README.md", | |
| 89 | 추가: "sha256": "c4642f094f643bf18fcc324e04a66b663dd668198d960fa324d30c9bdb8dd1b5" | |
| 45 | 90 | }, |
| 46 | 91 | { |
| 47 | 92 | "path": "tests/rust-app-ui/fake.rs", |
| @@ -52,15 +97,33 @@ | ||
| 52 | 97 | "sha256": "303cff6a9452b43db62af21ad906aef49279f7bf23136e2166793d4118d951dc" |
| 53 | 98 | }, |
| 54 | 99 | { |
| 55 | 삭제: "path": "tests/rust-app-ui/README.md", | |
| 56 | 삭제: "sha256": "942e108820d43ba9a70ba013cd7f1683d8bb90699315bda179ca95c4a15a736e" | |
| 100 | 추가: "path": "tests/rust-app-ui/regressions.rs", | |
| 101 | 추가: "sha256": "a4c3685a380cb73fd506a290270b2a5308529ef4f843c203127c2bc9a2df2a80" | |
| 102 | 추가: }, | |
| 103 | 추가: { | |
| 104 | 추가: "path": "tests/rust-app-real-worker/formats.rs", | |
| 105 | 추가: "sha256": "50532a4ee144ab533a43e1fefa5d1baf1131638892b585c20c9d4715a904e006" | |
| 57 | 106 | } |
| 58 | 107 | ], |
| 59 | 108 | "review_regressions": [ |
| 60 | 109 | "실제 풀기 버튼의 ZIP/TAR/TAR.GZ/GZIP 출력명 계약", |
| 61 | 110 | "비 GZIP 출력명 요청의 연결 전 거부", |
| 62 | 111 | "가짜 작업자의 형식별 출력명 검증", |
| 63 | 삭제: "Start 전송 실패 시 양쪽 EOF/child wait까지 연결 보존과 닫기/교체 차단" | |
| 112 | 추가: "Start 전송 실패 시 양쪽 EOF/child wait까지 연결 보존과 닫기/교체 차단", | |
| 113 | 추가: "오류 후 명시적 정리는 child wait 전에 닫기를 허용하지 않음", | |
| 114 | 추가: "정상 정리 신호는 EOF를 대신하지 않음", | |
| 115 | 추가: "정상 종료 뒤 채널 닫힘과 늦은 취소가 최종 결과를 오류로 바꾸지 않음", | |
| 116 | 추가: "child 회수 전 늦은 취소의 실제 작업자 경합 100회와 Terminal 없는 종료의 실패 유지" | |
| 64 | 117 | ], |
| 65 | 삭제: "before_review_fix": "Targeted regressions reproduced 3 failures with 16 existing tests passing before the product fix; final targeted suite passed 20 tests." | |
| 118 | 추가: "before_review_fix": "Earlier PR62 fixes reproduced 3 failures before repair. Integration tests additionally reproduced normal channel shutdown and late-cancel races before repair. PR68 review race reproduced with the new test before repair; all 100 iterations passed after repair.", | |
| 119 | 추가: "approved_ui_head": "423a7c80c9d7182e07d29adee03a97d09a19b11f", | |
| 120 | 추가: "tested_local_head": "0f26ed65d784b9cfb332168f3f3c619d53566325", | |
| 121 | 추가: "real_worker_tests_passed": 11, | |
| 122 | 추가: "runner_tests_passed": 17, | |
| 123 | 추가: "format_contract_tests_passed": 2, | |
| 124 | 추가: "prerequisite_heads": { | |
| 125 | 추가: "PR68": "d2db6625c50376de363670ee5658060445b433d1", | |
| 126 | 추가: "PR69": "745c62b746bb1546cdcbe0440a1446b6d3004b80" | |
| 127 | 추가: }, | |
| 128 | 추가: "format_extension": "Existing tags 0..3 unchanged; SevenZip=4. Full ListEnd golden frame, both platform identities and Extract codec roundtrip verified." | |
| 66 | 129 | } |