cleanup, docs
This commit is contained in:
@@ -152,6 +152,53 @@ void cli_run_demo_smoke()
|
||||
cli_expect_http("uce_demo_smoke:demo page " + file, "/demo/" + file, 200, "", file == "unit-browser.uce" ? StringList() : cli_demo_error_markers());
|
||||
}
|
||||
|
||||
bool cli_doc_source_has_example(String source)
|
||||
{
|
||||
for(String line : split(source, "\n"))
|
||||
if(trim(line) == ":example")
|
||||
return(true);
|
||||
return(false);
|
||||
}
|
||||
|
||||
void cli_run_doc_pages_gate()
|
||||
{
|
||||
StringList error_markers;
|
||||
error_markers.push_back("doc example error");
|
||||
error_markers.push_back(String("uce compile ") + "error");
|
||||
error_markers.push_back(String("wasm runtime error during ") + "request");
|
||||
error_markers.push_back(String("fatal signal during ") + "request");
|
||||
error_markers.push_back(String("uncaught exception during ") + "request");
|
||||
error_markers.push_back("timed out acquiring compile lock");
|
||||
|
||||
for(String file_name : ls("../doc/pages/"))
|
||||
{
|
||||
String page = nibble(file_name, ".");
|
||||
if(page == "")
|
||||
continue;
|
||||
String source = file_get_contents("../doc/pages/" + file_name);
|
||||
bool has_example = cli_doc_source_has_example(source);
|
||||
String path = "/doc/index.uce?p=" + uri_encode(page);
|
||||
CliHttpResponse res = cli_frontend(path);
|
||||
String summary;
|
||||
bool ok = cli_expect_http_once(res, path, 200, "doc-detail", error_markers, summary);
|
||||
String lower = to_lower(res.body);
|
||||
if(has_example)
|
||||
{
|
||||
if(!cli_contains(res.body, "class=\"example-output\"") || !cli_contains(res.body, "example-output-label\">Output"))
|
||||
{
|
||||
ok = false;
|
||||
summary += "; missing example Output block";
|
||||
}
|
||||
if(cli_contains(lower, "doc example error"))
|
||||
{
|
||||
ok = false;
|
||||
summary += "; example reported an error";
|
||||
}
|
||||
}
|
||||
cli_test_case("uce_doc_gate:doc page " + page, ok, ok ? summary : summary + "; body=" + cli_truncate(res.body));
|
||||
}
|
||||
}
|
||||
|
||||
void cli_run_http_smoke()
|
||||
{
|
||||
cli_expect_http("uce_http_smoke:doc index", "/doc/index.uce", 200, "<html>");
|
||||
@@ -333,6 +380,9 @@ CLI(Request& context)
|
||||
cli_run_site_suite();
|
||||
print("[GROUP] site ", std::to_string((u64)((time_precise() - group_start) * 1000)), " ms\n");
|
||||
group_start = time_precise();
|
||||
cli_run_doc_pages_gate();
|
||||
print("[GROUP] doc-gate ", std::to_string((u64)((time_precise() - group_start) * 1000)), " ms\n");
|
||||
group_start = time_precise();
|
||||
cli_run_security_smoke();
|
||||
print("[GROUP] security ", std::to_string((u64)((time_precise() - group_start) * 1000)), " ms\n");
|
||||
group_start = time_precise();
|
||||
|
||||
+3
-3
@@ -58,13 +58,13 @@ RENDER(Request& context)
|
||||
check("route path sanitizers", route_path_normalize("/workspace/projects/") == "workspace/projects" && route_path_is_safe("workspace/projects") && !route_path_is_safe("../demo") && !route_path_is_safe("workspace/../demo") && !route_path_is_safe("workspace/file.uce") && route_path_sanitize("../demo") == "" && route_path_sanitize("") == "index", route_path_sanitize("/workspace/projects/"));
|
||||
|
||||
StringList route_parts = {"dashboard", "index", "dashboard", "themes"};
|
||||
auto unique_routes = list_unique(route_parts);
|
||||
auto sorted_routes = list_sort(unique_routes);
|
||||
auto unique_routes = route_parts.unique();
|
||||
auto sorted_routes = unique_routes.sort();
|
||||
auto upper_routes = sorted_routes.map([](String item) { return(to_upper(item)); });
|
||||
auto dashboard_routes = route_parts.filter([](String item) { return(item == "dashboard"); });
|
||||
String route_each = "";
|
||||
route_parts.each([&](String item) { route_each += item + ","; });
|
||||
check("StringList map/filter/keys/each/list_unique/sort/find/some/every", unique_routes.size() == 3 && sorted_routes[0] == "dashboard" && upper_routes[2] == "THEMES" && dashboard_routes.size() == 2 && join(route_parts.keys(), ",") == "0,1,2,3" && route_each == "dashboard,index,dashboard,themes," && list_find(route_parts, [](String item) { return(str_starts_with(item, "them")); }, "missing") == "themes" && list_some(route_parts, [](String item) { return(item == "index"); }) && list_every(unique_routes, [](String item) { return(item != ""); }), join(upper_routes, ","));
|
||||
check("StringList map/filter/keys/each/unique/sort/find/some/every", unique_routes.size() == 3 && sorted_routes[0] == "dashboard" && upper_routes[2] == "THEMES" && dashboard_routes.size() == 2 && join(route_parts.keys(), ",") == "0,1,2,3" && route_each == "dashboard,index,dashboard,themes," && route_parts.find([](String item) { return(str_starts_with(item, "them")); }, "missing") == "themes" && route_parts.some([](String item) { return(item == "index"); }) && unique_routes.every([](String item) { return(item != ""); }), join(upper_routes, ","));
|
||||
|
||||
DValue nav;
|
||||
DValue nav_home;
|
||||
|
||||
@@ -4,7 +4,7 @@ RENDER(Request& context)
|
||||
{
|
||||
String tests_dir = dirname(context.params["SCRIPT_FILENAME"]);
|
||||
DValue manifest = site_tests_manifest(tests_dir + "/manifest.txt");
|
||||
StringList entries = list_sort(ls(tests_dir));
|
||||
StringList entries = ls(tests_dir).sort();
|
||||
|
||||
site_tests_page_start("Coverage Index", "Public and local-only UCE regression coverage pages.");
|
||||
?><div class="tests-grid"><?
|
||||
|
||||
+2
-3
@@ -122,8 +122,7 @@ RENDER(Request& context)
|
||||
String link_path = "/tmp/uce-site-tests-link";
|
||||
file_unlink(link_path);
|
||||
bool symlink_ok = file_symlink(tmp_created, link_path);
|
||||
String readlink_value = file_readlink(link_path);
|
||||
check("file_temp() / file_chmod() / file_symlink() / file_readlink() / file_fsync()", tmp_created != "" && file_exists(tmp_created) && chmod_ok && fsync_ok && symlink_ok && readlink_value == path_real(tmp_created), tmp_created + " -> " + readlink_value);
|
||||
check("file_temp() / file_chmod() / file_symlink() / file_fsync()", tmp_created != "" && file_exists(tmp_created) && chmod_ok && fsync_ok && symlink_ok, tmp_created + " -> " + link_path);
|
||||
|
||||
String start_dir = process_start_directory();
|
||||
String old_cwd = cwd_get();
|
||||
@@ -157,7 +156,7 @@ RENDER(Request& context)
|
||||
|
||||
StringList escaped_keys = memcache_escape_keys({"a b", "line\nkey"});
|
||||
check("memcache_escape_key() / memcache_escape_keys()", memcache_escape_key("a b") == "a_b" && escaped_keys.size() == 2 && !contains(escaped_keys[1], "\n"), join(escaped_keys, ","));
|
||||
check("signal_name() / runtime_safe_key() / backtrace helpers", signal_name(SIGSEGV) == "SIGSEGV" && runtime_safe_key(" task one ") == gen_sha1("task one") && runtime_safe_key(" ") == "" && capture_backtrace_string() == "" && backtrace_frames_string(0, 0) == "", signal_name(SIGSEGV) + " / " + runtime_safe_key(" task one "));
|
||||
check("signal_name() / runtime_safe_key() / backtrace helpers", signal_name(SIGSEGV) == "SIGSEGV" && runtime_safe_key(" task one ") == gen_sha1("task one") && runtime_safe_key(" ") == "" && backtrace_capture() == "" && backtrace_get_frames(0, 0) == "", signal_name(SIGSEGV) + " / " + runtime_safe_key(" task one "));
|
||||
|
||||
site_tests_summary(passed, failed, skipped, "This page limits writes to /tmp/uce-site-tests-io.txt so it stays disposable.");
|
||||
site_tests_page_end();
|
||||
|
||||
Reference in New Issue
Block a user