Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions experiments/shell/local_shell_diagnostics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ inline void local_shell_progress(const std::filesystem::path& directory, std::st
raw.close(); require(bool(raw), "local shell private output write failed");
}
}
inline void local_shell_size_readiness(const std::filesystem::path& directory, std::string_view role,
unsigned long columns, unsigned long rows, bool settled,
bool marker_present, unsigned long observed_bytes) {
require(role=="cmd" || role=="powershell" || role=="pwsh" || role=="wsl", "invalid local shell diagnostic role");
std::ofstream progress(directory/"shells-size-readiness.jsonl",std::ios::binary|std::ios::app);
progress<<"{\"schema\":\"termforge-local-shell-size-readiness-v1\",\"role\":\""<<role
<<"\",\"columns\":"<<columns<<",\"rows\":"<<rows
<<",\"settled\":"<<(settled?"true":"false")
<<",\"marker_present\":"<<(marker_present?"true":"false")
<<",\"observed_output_tail_bytes\":"<<observed_bytes<<"}\n";
progress.close(); require(bool(progress), "local shell size readiness write failed");
}
} // namespace tf_shell_test
15 changes: 13 additions & 2 deletions experiments/shell/workspace_clipboard_scenario.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,22 @@ inline void Workspace::scenario_clipboard() {
} else if(stage_==3 && evidence.receiver->checkpoint()) {
require(captured()==evidence.baseline(),"clipboard receiver baseline differs");
evidence.receiver->release();
// Setup writes are not the product behaviour under test; Explorer or a
// previous case can hold the desktop clipboard for a moment, so give the
// fixture a small bounded retry instead of failing the whole scenario.
auto prepare_clipboard = [&](auto&& write) {
std::string last;
for (int attempt = 0; attempt < 4; ++attempt) {
try { write(); return; } catch (const std::exception& error) { last = error.what(); }
if (attempt + 1 != 4) Sleep(50 * (attempt + 1));
}
throw std::runtime_error(last);
};
try {
if(evidence.index==0) {
tf_shell::write_unicode_clipboard(window_,u"OCCUPIED_MUST_NOT_SEND");
prepare_clipboard([&] { tf_shell::write_unicode_clipboard(window_,u"OCCUPIED_MUST_NOT_SEND"); });
evidence.owner=std::make_unique<tf_shell_test::ClipboardScenarioOwner>(false);
} else if(evidence.index==1) tf_shell_test::write_oversized_clipboard(window_);
} else if(evidence.index==1) prepare_clipboard([&] { tf_shell_test::write_oversized_clipboard(window_); });
else evidence.owner=std::make_unique<tf_shell_test::ClipboardScenarioOwner>(true);
} catch(const std::exception& error) {
throw std::runtime_error(std::string("clipboard case=")+evidence.name()+
Expand Down
12 changes: 12 additions & 0 deletions experiments/shell/workspace_shells_scenario.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ inline void Workspace::scenario_shells() {
selected(Group::main)->render_to(frame.dc, main.left, main.top);
selected(Group::bottom)->render_to(frame.dc, bottom.left, bottom.top);
frame.save(image_);
// #80: which readiness condition was actually missing when the deadline hit.
const auto diagnostic_directory = std::filesystem::path(image_).parent_path();
for (const auto group : {Group::bottom, Group::main}) for (auto& tab : group_tabs(group)) {
if (!tab.launch) continue;
const auto [columns, rows] = tab.shell->grid_dimensions();
const std::string role(tab.launch->kind.begin(), tab.launch->kind.end());
tf_shell_test::local_shell_size_readiness(
diagnostic_directory, role, static_cast<unsigned long>(columns), static_cast<unsigned long>(rows),
tab.shell->settled(),
tab.shell->contains_line("TF_SIZE_" + std::to_string(columns) + "x" + std::to_string(rows)),
static_cast<unsigned long>(tab.shell->observed_output().size()));
}
require(false, ("workspace shells scenario timeout at stage " + std::to_string(stage_)).c_str());
}
const auto directory = std::filesystem::path(image_).parent_path();
Expand Down
Loading