//! Build script for P2P Library - Zig 0.15+ //! //! This build file provides targets for building, testing, and running //! the P2P networking library and its examples. const std = @import("std"); pub fn build(b: *std.Build) void { // Standard target and optimization options const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // ============================================================ // Core Module // ============================================================ const core_module = b.addModule("core", .{ .root_source_file = b.path("src/core.zig"), .target = target, .optimize = optimize, }); // ============================================================ // Network Module // ============================================================ const network_module = b.addModule("network", .{ .root_source_file = b.path("src/network.zig"), .target = target, .optimize = optimize, }); network_module.addImport("core", core_module); // ============================================================ // Protocol Module // ============================================================ const protocol_module = b.addModule("protocol", .{ .root_source_file = b.path("src/protocol.zig"), .target = target, .optimize = optimize, }); protocol_module.addImport("core", core_module); protocol_module.addImport("network", network_module); // ============================================================ // Files Module // ============================================================ const files_module = b.addModule("files", .{ .root_source_file = b.path("src/files.zig"), .target = target, .optimize = optimize, .link_libc = true, }); files_module.addImport("core", core_module); files_module.addImport("protocol", protocol_module); // ============================================================ // Noise Protocol Module // ============================================================ const noise_module = b.addModule("noise", .{ .root_source_file = b.path("src/noise/noise.zig"), .target = target, .optimize = optimize, }); // Add noise to network module for SecureConnection network_module.addImport("noise", noise_module); // ============================================================ // Main P2P Module // ============================================================ const p2p_module = b.addModule("p2p", .{ .root_source_file = b.path("src/p2p.zig"), .target = target, .optimize = optimize, }); p2p_module.addImport("core", core_module); p2p_module.addImport("network", network_module); p2p_module.addImport("protocol", protocol_module); p2p_module.addImport("files", files_module); p2p_module.addImport("noise", noise_module); // ============================================================ // MWP (Mutual Witness Protocol) Core Library // ============================================================ const mwp_lib_module = b.addModule("mwp_lib", .{ .root_source_file = b.path("src/mwp/mwp.zig"), .target = target, .optimize = optimize, }); // ============================================================ // MWP Integration Module (user-facing API) // ============================================================ const mwp_module = b.addModule("mwp", .{ .root_source_file = b.path("src/mwp_integration.zig"), .target = target, .optimize = optimize, }); mwp_module.addImport("p2p", p2p_module); mwp_module.addImport("mwp_lib", mwp_lib_module); // ============================================================ // Example Executables // ============================================================ // Server example module const server_module = b.createModule(.{ .root_source_file = b.path("examples/server.zig"), .target = target, .optimize = .Debug, }); server_module.addImport("core", core_module); server_module.addImport("network", network_module); server_module.addImport("p2p", p2p_module); const example_server = b.addExecutable(.{ .name = "example-server", .root_module = server_module, }); b.installArtifact(example_server); const run_server = b.addRunArtifact(example_server); run_server.step.dependOn(b.getInstallStep()); const run_server_step = b.step("run-server", "Run the example server"); run_server_step.dependOn(&run_server.step); // Client example module const client_module = b.createModule(.{ .root_source_file = b.path("examples/client.zig"), .target = target, .optimize = .Debug, }); client_module.addImport("core", core_module); client_module.addImport("network", network_module); client_module.addImport("p2p", p2p_module); const example_client = b.addExecutable(.{ .name = "example-client", .root_module = client_module, }); b.installArtifact(example_client); const run_client = b.addRunArtifact(example_client); run_client.step.dependOn(b.getInstallStep()); const run_client_step = b.step("run-client", "Run the example client"); run_client_step.dependOn(&run_client.step); // MWP Demo example const mwp_demo_module = b.createModule(.{ .root_source_file = b.path("examples/mwp_demo.zig"), .target = target, .optimize = .Debug, }); mwp_demo_module.addImport("p2p", p2p_module); mwp_demo_module.addImport("mwp", mwp_module); const mwp_demo = b.addExecutable(.{ .name = "mwp-demo", .root_module = mwp_demo_module, }); b.installArtifact(mwp_demo); const run_mwp = b.addRunArtifact(mwp_demo); run_mwp.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_mwp.addArgs(args); } const run_mwp_step = b.step("run-mwp", "Run the MWP demo"); run_mwp_step.dependOn(&run_mwp.step); // Encrypted server example (Noise Protocol) const encrypted_server_module = b.createModule(.{ .root_source_file = b.path("examples/encrypted_server.zig"), .target = target, .optimize = .Debug, }); encrypted_server_module.addImport("core", core_module); encrypted_server_module.addImport("network", network_module); encrypted_server_module.addImport("p2p", p2p_module); const encrypted_server = b.addExecutable(.{ .name = "encrypted-server", .root_module = encrypted_server_module, }); b.installArtifact(encrypted_server); const run_encrypted_server = b.addRunArtifact(encrypted_server); run_encrypted_server.step.dependOn(b.getInstallStep()); const run_encrypted_server_step = b.step("run-encrypted-server", "Run the encrypted P2P server"); run_encrypted_server_step.dependOn(&run_encrypted_server.step); // Encrypted client example (Noise Protocol) const encrypted_client_module = b.createModule(.{ .root_source_file = b.path("examples/encrypted_client.zig"), .target = target, .optimize = .Debug, }); encrypted_client_module.addImport("core", core_module); encrypted_client_module.addImport("network", network_module); encrypted_client_module.addImport("p2p", p2p_module); const encrypted_client = b.addExecutable(.{ .name = "encrypted-client", .root_module = encrypted_client_module, }); b.installArtifact(encrypted_client); const run_encrypted_client = b.addRunArtifact(encrypted_client); run_encrypted_client.step.dependOn(b.getInstallStep()); const run_encrypted_client_step = b.step("run-encrypted-client", "Run the encrypted P2P client"); run_encrypted_client_step.dependOn(&run_encrypted_client.step); // P2P example module const p2p_example_module = b.createModule(.{ .root_source_file = b.path("examples/p2p_example.zig"), .target = target, .optimize = .Debug, }); p2p_example_module.addImport("core", core_module); p2p_example_module.addImport("network", network_module); p2p_example_module.addImport("protocol", protocol_module); p2p_example_module.addImport("files", files_module); p2p_example_module.addImport("p2p", p2p_module); const example_p2p = b.addExecutable(.{ .name = "example-p2p", .root_module = p2p_example_module, }); b.installArtifact(example_p2p); const run_p2p = b.addRunArtifact(example_p2p); run_p2p.step.dependOn(b.getInstallStep()); const run_p2p_step = b.step("run-p2p", "Run the main P2P example"); run_p2p_step.dependOn(&run_p2p.step); // Network integration test const network_test_module = b.createModule(.{ .root_source_file = b.path("examples/network_test.zig"), .target = target, .optimize = .Debug, }); network_test_module.addImport("core", core_module); const network_test = b.addExecutable(.{ .name = "network-test", .root_module = network_test_module, }); b.installArtifact(network_test); const run_network_test = b.addRunArtifact(network_test); run_network_test.step.dependOn(b.getInstallStep()); const run_network_test_step = b.step("run-network-test", "Run real network integration test"); run_network_test_step.dependOn(&run_network_test.step); // Integration test const integration_test_module = b.createModule(.{ .root_source_file = b.path("examples/integration_test.zig"), .target = target, .optimize = .Debug, }); integration_test_module.addImport("core", core_module); integration_test_module.addImport("network", network_module); integration_test_module.addImport("protocol", protocol_module); integration_test_module.addImport("files", files_module); integration_test_module.addImport("p2p", p2p_module); const integration_test = b.addExecutable(.{ .name = "integration-test", .root_module = integration_test_module, }); b.installArtifact(integration_test); const run_integration_test = b.addRunArtifact(integration_test); run_integration_test.step.dependOn(b.getInstallStep()); const run_integration_step = b.step("run-integration-test", "Run P2P integration test"); run_integration_step.dependOn(&run_integration_test.step); // Real communication test const real_test_module = b.createModule(.{ .root_source_file = b.path("examples/real_test.zig"), .target = target, .optimize = .Debug, }); real_test_module.addImport("core", core_module); real_test_module.addImport("network", network_module); real_test_module.addImport("protocol", protocol_module); real_test_module.addImport("files", files_module); real_test_module.addImport("p2p", p2p_module); const real_test = b.addExecutable(.{ .name = "real-test", .root_module = real_test_module, }); b.installArtifact(real_test); const run_real_test = b.addRunArtifact(real_test); run_real_test.step.dependOn(b.getInstallStep()); const run_real_test_step = b.step("run-real-test", "Run real P2P communication test"); run_real_test_step.dependOn(&run_real_test.step); // Protocol example const protocol_example_module = b.createModule(.{ .root_source_file = b.path("examples/protocol_example.zig"), .target = target, .optimize = .Debug, }); protocol_example_module.addImport("core", core_module); protocol_example_module.addImport("protocol", protocol_module); const protocol_example = b.addExecutable(.{ .name = "protocol-example", .root_module = protocol_example_module, }); b.installArtifact(protocol_example); const run_protocol_example = b.addRunArtifact(protocol_example); run_protocol_example.step.dependOn(b.getInstallStep()); const run_protocol_example_step = b.step("run-protocol-example", "Run protocol message example"); run_protocol_example_step.dependOn(&run_protocol_example.step); // File server example const file_server_module = b.createModule(.{ .root_source_file = b.path("examples/file_server.zig"), .target = target, .optimize = .Debug, }); file_server_module.addImport("core", core_module); file_server_module.addImport("files", files_module); file_server_module.addImport("p2p", p2p_module); const file_server = b.addExecutable(.{ .name = "file-server", .root_module = file_server_module, }); b.installArtifact(file_server); const run_file_server = b.addRunArtifact(file_server); run_file_server.step.dependOn(b.getInstallStep()); const run_file_server_step = b.step("run-file-server", "Run file server example"); run_file_server_step.dependOn(&run_file_server.step); // File transfer test const file_transfer_test_module = b.createModule(.{ .root_source_file = b.path("examples/file_transfer_test.zig"), .target = target, .optimize = .Debug, }); file_transfer_test_module.addImport("core", core_module); file_transfer_test_module.addImport("files", files_module); file_transfer_test_module.addImport("p2p", p2p_module); const file_transfer_test = b.addExecutable(.{ .name = "file-transfer-test", .root_module = file_transfer_test_module, }); b.installArtifact(file_transfer_test); const run_file_transfer_test = b.addRunArtifact(file_transfer_test); run_file_transfer_test.step.dependOn(b.getInstallStep()); const run_file_transfer_test_step = b.step("run-file-transfer-test", "Run file transfer integration test"); run_file_transfer_test_step.dependOn(&run_file_transfer_test.step); // Multi-peer download test const multi_peer_test_module = b.createModule(.{ .root_source_file = b.path("examples/multi_peer_download_test.zig"), .target = target, .optimize = .ReleaseFast, }); multi_peer_test_module.addImport("core", core_module); multi_peer_test_module.addImport("files", files_module); multi_peer_test_module.addImport("p2p", p2p_module); const multi_peer_test = b.addExecutable(.{ .name = "multi-peer-test", .root_module = multi_peer_test_module, }); b.installArtifact(multi_peer_test); const run_multi_peer_test = b.addRunArtifact(multi_peer_test); run_multi_peer_test.setCwd(b.path(".")); run_multi_peer_test.step.dependOn(b.getInstallStep()); const run_multi_peer_test_step = b.step("run-multi-peer-test", "Run multi-peer download test (1GB from 10 peers)"); run_multi_peer_test_step.dependOn(&run_multi_peer_test.step); // Multi-file swarm test (9 peers, 2 files, multiple senders/receivers) const multi_file_swarm_module = b.createModule(.{ .root_source_file = b.path("examples/multi_file_swarm_test.zig"), .target = target, .optimize = .ReleaseFast, }); multi_file_swarm_module.addImport("core", core_module); multi_file_swarm_module.addImport("p2p", p2p_module); multi_file_swarm_module.addImport("files", files_module); const multi_file_swarm_test = b.addExecutable(.{ .name = "multi-file-swarm-test", .root_module = multi_file_swarm_module, }); b.installArtifact(multi_file_swarm_test); const run_multi_file_swarm = b.addRunArtifact(multi_file_swarm_test); run_multi_file_swarm.setCwd(b.path(".")); run_multi_file_swarm.step.dependOn(b.getInstallStep()); const run_multi_file_swarm_step = b.step("run-swarm-test", "Run multi-file swarm test (9 peers, 2 files)"); run_multi_file_swarm_step.dependOn(&run_multi_file_swarm.step); // Swarm Chaos Test - comprehensive resilience testing const swarm_chaos_module = b.createModule(.{ .root_source_file = b.path("examples/swarm_chaos_test.zig"), .target = target, .optimize = .ReleaseFast, // Use release for realistic performance }); swarm_chaos_module.addImport("core", core_module); swarm_chaos_module.addImport("p2p", p2p_module); swarm_chaos_module.addImport("files", files_module); const swarm_chaos_test = b.addExecutable(.{ .name = "swarm-chaos-test", .root_module = swarm_chaos_module, }); b.installArtifact(swarm_chaos_test); const run_swarm_chaos = b.addRunArtifact(swarm_chaos_test); run_swarm_chaos.setCwd(b.path(".")); run_swarm_chaos.step.dependOn(b.getInstallStep()); const run_swarm_chaos_step = b.step("run-chaos-test", "Run swarm chaos test (seeder failure, cascading, late joiners)"); run_swarm_chaos_step.dependOn(&run_swarm_chaos.step); // DHT end-to-end test const dht_test_module = b.createModule(.{ .root_source_file = b.path("examples/dht_test.zig"), .target = target, .optimize = .Debug, }); dht_test_module.addImport("core", core_module); dht_test_module.addImport("p2p", p2p_module); const dht_test = b.addExecutable(.{ .name = "dht-test", .root_module = dht_test_module, }); b.installArtifact(dht_test); const run_dht_test = b.addRunArtifact(dht_test); run_dht_test.step.dependOn(b.getInstallStep()); const run_dht_test_step = b.step("run-dht-test", "Run DHT peer discovery end-to-end test"); run_dht_test_step.dependOn(&run_dht_test.step); // Basic file share example const basic_file_share_module = b.createModule(.{ .root_source_file = b.path("examples/basic_file_share.zig"), .target = target, .optimize = .Debug, }); basic_file_share_module.addImport("core", core_module); basic_file_share_module.addImport("p2p", p2p_module); const basic_file_share = b.addExecutable(.{ .name = "basic-file-share", .root_module = basic_file_share_module, }); b.installArtifact(basic_file_share); const run_basic_file_share = b.addRunArtifact(basic_file_share); run_basic_file_share.step.dependOn(b.getInstallStep()); const run_basic_file_share_step = b.step("run-basic-file-share", "Run basic file share example"); run_basic_file_share_step.dependOn(&run_basic_file_share.step); // File downloader example const file_downloader_module = b.createModule(.{ .root_source_file = b.path("examples/file_downloader.zig"), .target = target, .optimize = .Debug, }); file_downloader_module.addImport("core", core_module); file_downloader_module.addImport("files", files_module); file_downloader_module.addImport("p2p", p2p_module); const file_downloader = b.addExecutable(.{ .name = "file-downloader", .root_module = file_downloader_module, }); b.installArtifact(file_downloader); const run_file_downloader = b.addRunArtifact(file_downloader); run_file_downloader.step.dependOn(b.getInstallStep()); const run_file_downloader_step = b.step("run-file-downloader", "Run file downloader example"); run_file_downloader_step.dependOn(&run_file_downloader.step); // Network discovery example const network_discovery_module = b.createModule(.{ .root_source_file = b.path("examples/network_discovery.zig"), .target = target, .optimize = .Debug, }); network_discovery_module.addImport("core", core_module); network_discovery_module.addImport("network", network_module); network_discovery_module.addImport("protocol", protocol_module); network_discovery_module.addImport("p2p", p2p_module); const network_discovery = b.addExecutable(.{ .name = "network-discovery", .root_module = network_discovery_module, }); b.installArtifact(network_discovery); const run_network_discovery = b.addRunArtifact(network_discovery); run_network_discovery.step.dependOn(b.getInstallStep()); const run_network_discovery_step = b.step("run-network-discovery", "Run network discovery example"); run_network_discovery_step.dependOn(&run_network_discovery.step); // Complete app example const complete_app_module = b.createModule(.{ .root_source_file = b.path("examples/complete_app.zig"), .target = target, .optimize = .Debug, }); complete_app_module.addImport("core", core_module); complete_app_module.addImport("network", network_module); complete_app_module.addImport("protocol", protocol_module); complete_app_module.addImport("files", files_module); complete_app_module.addImport("p2p", p2p_module); const complete_app = b.addExecutable(.{ .name = "complete-app", .root_module = complete_app_module, }); b.installArtifact(complete_app); const run_complete_app = b.addRunArtifact(complete_app); run_complete_app.step.dependOn(b.getInstallStep()); const run_complete_app_step = b.step("run-complete-app", "Run complete P2P application example"); run_complete_app_step.dependOn(&run_complete_app.step); // Benchmark example const benchmark_module = b.createModule(.{ .root_source_file = b.path("examples/benchmark.zig"), .target = target, .optimize = .ReleaseFast, }); benchmark_module.addImport("core", core_module); const benchmark = b.addExecutable(.{ .name = "benchmark", .root_module = benchmark_module, }); b.installArtifact(benchmark); const run_benchmark = b.addRunArtifact(benchmark); run_benchmark.step.dependOn(b.getInstallStep()); const run_benchmark_step = b.step("run-benchmark", "Run performance benchmarks"); run_benchmark_step.dependOn(&run_benchmark.step); // ============================================================ // A2A (Agent-to-Agent) Examples // ============================================================ // A2A Protocol module const a2a_protocol_module = b.createModule(.{ .root_source_file = b.path("examples/a2a/protocol.zig"), .target = target, .optimize = optimize, }); // LLM Agent const llm_agent_module = b.createModule(.{ .root_source_file = b.path("examples/a2a/llm_agent.zig"), .target = target, .optimize = optimize, }); llm_agent_module.addImport("p2p", p2p_module); llm_agent_module.addImport("network", network_module); llm_agent_module.addImport("protocol", a2a_protocol_module); const llm_agent = b.addExecutable(.{ .name = "llm-agent", .root_module = llm_agent_module, }); b.installArtifact(llm_agent); const run_llm_agent = b.addRunArtifact(llm_agent); run_llm_agent.step.dependOn(b.getInstallStep()); if (b.args) |args| run_llm_agent.addArgs(args); const run_llm_agent_step = b.step("run-llm-agent", "Run A2A LLM agent (wraps Ollama)"); run_llm_agent_step.dependOn(&run_llm_agent.step); // Client Agent const client_agent_module = b.createModule(.{ .root_source_file = b.path("examples/a2a/client_agent.zig"), .target = target, .optimize = optimize, }); client_agent_module.addImport("p2p", p2p_module); client_agent_module.addImport("network", network_module); client_agent_module.addImport("protocol", a2a_protocol_module); const client_agent = b.addExecutable(.{ .name = "client-agent", .root_module = client_agent_module, }); b.installArtifact(client_agent); const run_client_agent = b.addRunArtifact(client_agent); run_client_agent.step.dependOn(b.getInstallStep()); if (b.args) |args| run_client_agent.addArgs(args); const run_client_agent_step = b.step("run-client-agent", "Run A2A client agent"); run_client_agent_step.dependOn(&run_client_agent.step); // Unified A2A Agent (symmetric - can both send and receive) const a2a_agent_module = b.createModule(.{ .root_source_file = b.path("examples/a2a/agent.zig"), .target = target, .optimize = optimize, }); a2a_agent_module.addImport("p2p", p2p_module); a2a_agent_module.addImport("network", network_module); a2a_agent_module.addImport("protocol", a2a_protocol_module); const a2a_agent = b.addExecutable(.{ .name = "a2a-agent", .root_module = a2a_agent_module, }); b.installArtifact(a2a_agent); const run_a2a_agent = b.addRunArtifact(a2a_agent); run_a2a_agent.step.dependOn(b.getInstallStep()); if (b.args) |args| run_a2a_agent.addArgs(args); const run_a2a_agent_step = b.step("run-a2a-agent", "Run symmetric A2A agent (can send & receive)"); run_a2a_agent_step.dependOn(&run_a2a_agent.step); // A2A Conversation (autonomous agent-to-agent discussion) const a2a_conversation_module = b.createModule(.{ .root_source_file = b.path("examples/a2a/conversation.zig"), .target = target, .optimize = optimize, }); a2a_conversation_module.addImport("p2p", p2p_module); a2a_conversation_module.addImport("network", network_module); a2a_conversation_module.addImport("protocol", a2a_protocol_module); const a2a_conversation = b.addExecutable(.{ .name = "a2a-conversation", .root_module = a2a_conversation_module, }); b.installArtifact(a2a_conversation); const run_a2a_conversation = b.addRunArtifact(a2a_conversation); run_a2a_conversation.step.dependOn(b.getInstallStep()); if (b.args) |args| run_a2a_conversation.addArgs(args); const run_a2a_conversation_step = b.step("run-a2a-conversation", "Run autonomous A2A conversation between two agents"); run_a2a_conversation_step.dependOn(&run_a2a_conversation.step); // A2A Swarm Agent (DHT-based agent discovery + A2A messaging) const swarm_agent_module = b.createModule(.{ .root_source_file = b.path("examples/a2a/swarm_agent.zig"), .target = target, .optimize = optimize, }); swarm_agent_module.addImport("p2p", p2p_module); swarm_agent_module.addImport("network", network_module); swarm_agent_module.addImport("protocol", a2a_protocol_module); const swarm_agent = b.addExecutable(.{ .name = "swarm-agent", .root_module = swarm_agent_module, }); b.installArtifact(swarm_agent); const run_swarm_agent = b.addRunArtifact(swarm_agent); run_swarm_agent.step.dependOn(b.getInstallStep()); if (b.args) |args| run_swarm_agent.addArgs(args); const run_swarm_agent_step = b.step("run-swarm-agent", "Run DHT-based A2A swarm agent"); run_swarm_agent_step.dependOn(&run_swarm_agent.step); // Resume test const resume_test_module = b.createModule(.{ .root_source_file = b.path("examples/resume_test.zig"), .target = target, .optimize = optimize, }); resume_test_module.addImport("core", core_module); resume_test_module.addImport("files", files_module); const resume_test = b.addExecutable(.{ .name = "resume-test", .root_module = resume_test_module, }); b.installArtifact(resume_test); const run_resume_test = b.addRunArtifact(resume_test); run_resume_test.step.dependOn(b.getInstallStep()); const run_resume_test_step = b.step("run-resume-test", "Run download resume tests"); run_resume_test_step.dependOn(&run_resume_test.step); // Interrupted transfer test const interrupted_test_module = b.createModule(.{ .root_source_file = b.path("examples/interrupted_transfer_test.zig"), .target = target, .optimize = optimize, }); interrupted_test_module.addImport("core", core_module); interrupted_test_module.addImport("files", files_module); const interrupted_test = b.addExecutable(.{ .name = "interrupted-transfer-test", .root_module = interrupted_test_module, }); b.installArtifact(interrupted_test); const run_interrupted_test = b.addRunArtifact(interrupted_test); run_interrupted_test.step.dependOn(b.getInstallStep()); const run_interrupted_test_step = b.step("run-interrupted-test", "Run interrupted file transfer resume test"); run_interrupted_test_step.dependOn(&run_interrupted_test.step); // Docker peer for cross-machine testing const docker_peer_module = b.createModule(.{ .root_source_file = b.path("docker-tests/peer.zig"), .target = target, .optimize = .ReleaseFast, }); docker_peer_module.addImport("core", core_module); docker_peer_module.addImport("network", network_module); docker_peer_module.addImport("protocol", protocol_module); docker_peer_module.addImport("files", files_module); docker_peer_module.addImport("p2p", p2p_module); const docker_peer = b.addExecutable(.{ .name = "docker-peer", .root_module = docker_peer_module, }); docker_peer.linkLibC(); // Required for fstatfs syscall b.installArtifact(docker_peer); // Build step for just the docker-peer binary (used by Docker builds) const build_docker_peer_step = b.step("docker-peer", "Build Docker test peer"); build_docker_peer_step.dependOn(&b.addInstallArtifact(docker_peer, .{}).step); const run_docker_peer = b.addRunArtifact(docker_peer); run_docker_peer.step.dependOn(b.getInstallStep()); const run_docker_peer_step = b.step("run-docker-peer", "Run Docker test peer"); run_docker_peer_step.dependOn(&run_docker_peer.step); // ============================================================ // Integration Tests (tests/ folder) // ============================================================ // Test NetworkBridge const test_bridge_module = b.createModule(.{ .root_source_file = b.path("tests/network/test_bridge.zig"), .target = target, .optimize = .Debug, }); test_bridge_module.addImport("core", core_module); test_bridge_module.addImport("network", network_module); const test_bridge = b.addTest(.{ .root_module = test_bridge_module, }); const run_test_bridge = b.addRunArtifact(test_bridge); const test_bridge_step = b.step("test-bridge", "Run NetworkBridge tests"); test_bridge_step.dependOn(&run_test_bridge.step); // Test NetworkManager Comprehensive const test_network_manager_module = b.createModule(.{ .root_source_file = b.path("tests/network/test_network_manager_comprehensive.zig"), .target = target, .optimize = .Debug, }); test_network_manager_module.addImport("core", core_module); test_network_manager_module.addImport("network", network_module); const test_network_manager = b.addTest(.{ .root_module = test_network_manager_module, }); const run_test_network_manager = b.addRunArtifact(test_network_manager); const test_network_manager_step = b.step("test-network-manager", "Run NetworkManager comprehensive tests"); test_network_manager_step.dependOn(&run_test_network_manager.step); // Test Protocol Security const test_security_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_security.zig"), .target = target, .optimize = .Debug, }); test_security_module.addImport("protocol", protocol_module); const test_security = b.addTest(.{ .root_module = test_security_module, }); const run_test_security = b.addRunArtifact(test_security); const test_security_step = b.step("test-security", "Run protocol security tests"); test_security_step.dependOn(&run_test_security.step); // Test Message Authentication (HMAC) const test_message_auth_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_message_auth.zig"), .target = target, .optimize = .Debug, }); test_message_auth_module.addImport("protocol", protocol_module); const test_message_auth = b.addTest(.{ .root_module = test_message_auth_module, }); const run_test_message_auth = b.addRunArtifact(test_message_auth); const test_message_auth_step = b.step("test-message-auth", "Run HMAC message authentication tests"); test_message_auth_step.dependOn(&run_test_message_auth.step); // Test Encryption Integration const test_encryption_integration_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_encryption_integration.zig"), .target = target, .optimize = .Debug, }); test_encryption_integration_module.addImport("protocol", protocol_module); const test_encryption_integration = b.addTest(.{ .root_module = test_encryption_integration_module, }); const run_test_encryption_integration = b.addRunArtifact(test_encryption_integration); const test_encryption_integration_step = b.step("test-encryption-integration", "Run encryption integration tests"); test_encryption_integration_step.dependOn(&run_test_encryption_integration.step); // Test Error Recovery const test_error_recovery_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_error_recovery.zig"), .target = target, .optimize = .Debug, }); test_error_recovery_module.addImport("core", core_module); test_error_recovery_module.addImport("network", network_module); test_error_recovery_module.addImport("protocol", protocol_module); test_error_recovery_module.addImport("files", files_module); test_error_recovery_module.addImport("p2p", p2p_module); const test_error_recovery = b.addTest(.{ .root_module = test_error_recovery_module, }); const run_test_error_recovery = b.addRunArtifact(test_error_recovery); const test_error_recovery_step = b.step("test-error-recovery", "Run error recovery tests"); test_error_recovery_step.dependOn(&run_test_error_recovery.step); // Test E2E File Transfer const test_e2e_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_e2e_transfer.zig"), .target = target, .optimize = .Debug, }); test_e2e_module.addImport("core", core_module); test_e2e_module.addImport("network", network_module); test_e2e_module.addImport("protocol", protocol_module); test_e2e_module.addImport("files", files_module); test_e2e_module.addImport("p2p", p2p_module); const test_e2e = b.addTest(.{ .root_module = test_e2e_module, }); const run_test_e2e = b.addRunArtifact(test_e2e); const test_e2e_step = b.step("test-e2e", "Run E2E file transfer tests"); test_e2e_step.dependOn(&run_test_e2e.step); // Test Real E2E (peer connection, messaging, lifecycle) const test_real_e2e_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_real_e2e.zig"), .target = target, .optimize = .Debug, }); test_real_e2e_module.addImport("core", core_module); test_real_e2e_module.addImport("network", network_module); test_real_e2e_module.addImport("p2p", p2p_module); const test_real_e2e = b.addTest(.{ .root_module = test_real_e2e_module, }); const run_test_real_e2e = b.addRunArtifact(test_real_e2e); const test_real_e2e_step = b.step("test-real-e2e", "Run real E2E integration tests"); test_real_e2e_step.dependOn(&run_test_real_e2e.step); // Test Noise Protocol Encrypted Connections const test_noise_connection_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_noise_connection.zig"), .target = target, .optimize = .Debug, }); test_noise_connection_module.addImport("core", core_module); test_noise_connection_module.addImport("network", network_module); test_noise_connection_module.addImport("protocol", protocol_module); test_noise_connection_module.addImport("p2p", p2p_module); test_noise_connection_module.addImport("noise", noise_module); const test_noise_connection = b.addTest(.{ .root_module = test_noise_connection_module, }); const run_test_noise_connection = b.addRunArtifact(test_noise_connection); const test_noise_connection_step = b.step("test-noise-connection", "Run Noise protocol encrypted connection tests"); test_noise_connection_step.dependOn(&run_test_noise_connection.step); // Test SecureConnection (comprehensive tests) const test_secure_connection_module = b.createModule(.{ .root_source_file = b.path("tests/network/test_secure_connection.zig"), .target = target, .optimize = .Debug, }); test_secure_connection_module.addImport("core", core_module); test_secure_connection_module.addImport("network", network_module); test_secure_connection_module.addImport("noise", noise_module); const test_secure_connection = b.addTest(.{ .root_module = test_secure_connection_module, }); const run_test_secure_connection = b.addRunArtifact(test_secure_connection); const test_secure_connection_step = b.step("test-secure-connection", "Run SecureConnection comprehensive tests"); test_secure_connection_step.dependOn(&run_test_secure_connection.step); // Test NAT traversal const test_nat_module = b.createModule(.{ .root_source_file = b.path("tests/network/test_nat.zig"), .target = target, .optimize = .Debug, }); test_nat_module.addImport("core", core_module); test_nat_module.addImport("network", network_module); const test_nat = b.addTest(.{ .root_module = test_nat_module, }); const run_test_nat = b.addRunArtifact(test_nat); const test_nat_step = b.step("test-nat", "Run NAT traversal tests"); test_nat_step.dependOn(&run_test_nat.step); // Test Replay Protection const test_replay_protection_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_replay_protection.zig"), .target = target, .optimize = .Debug, }); test_replay_protection_module.addImport("protocol", protocol_module); const test_replay_protection = b.addTest(.{ .root_module = test_replay_protection_module, }); const run_test_replay_protection = b.addRunArtifact(test_replay_protection); const test_replay_protection_step = b.step("test-replay-protection", "Run replay protection comprehensive tests"); test_replay_protection_step.dependOn(&run_test_replay_protection.step); // Test Replay Integration const test_replay_integration_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_replay_integration.zig"), .target = target, .optimize = .Debug, }); test_replay_integration_module.addImport("protocol", protocol_module); const test_replay_integration = b.addTest(.{ .root_module = test_replay_integration_module, }); const run_test_replay_integration = b.addRunArtifact(test_replay_integration); const test_replay_integration_step = b.step("test-replay-integration", "Run replay protection integration tests"); test_replay_integration_step.dependOn(&run_test_replay_integration.step); // Test Transfer Protocol const test_transfer_protocol_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_transfer_protocol.zig"), .target = target, .optimize = .Debug, }); test_transfer_protocol_module.addImport("files", files_module); const test_transfer_protocol = b.addTest(.{ .root_module = test_transfer_protocol_module, }); const run_test_transfer_protocol = b.addRunArtifact(test_transfer_protocol); const test_transfer_protocol_step = b.step("test-transfer-protocol", "Run transfer protocol comprehensive tests"); test_transfer_protocol_step.dependOn(&run_test_transfer_protocol.step); // Test Upload Module const test_upload_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_upload.zig"), .target = target, .optimize = .Debug, }); test_upload_module.addImport("files", files_module); test_upload_module.addImport("core", core_module); const test_upload = b.addTest(.{ .root_module = test_upload_module, }); const run_test_upload = b.addRunArtifact(test_upload); const test_upload_step = b.step("test-upload", "Run upload module comprehensive tests"); test_upload_step.dependOn(&run_test_upload.step); // Test Manager Comprehensive const test_manager_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_manager_comprehensive.zig"), .target = target, .optimize = .Debug, }); test_manager_module.addImport("files", files_module); test_manager_module.addImport("core", core_module); const test_manager = b.addTest(.{ .root_module = test_manager_module, }); const run_test_manager = b.addRunArtifact(test_manager); const test_manager_step = b.step("test-manager", "Run file manager comprehensive tests"); test_manager_step.dependOn(&run_test_manager.step); // Test Manager Integration (with real files) const test_manager_integration_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_manager_integration.zig"), .target = target, .optimize = .Debug, }); test_manager_integration_module.addImport("files", files_module); test_manager_integration_module.addImport("core", core_module); const test_manager_integration = b.addTest(.{ .root_module = test_manager_integration_module, }); const run_test_manager_integration = b.addRunArtifact(test_manager_integration); const test_manager_integration_step = b.step("test-manager-integration", "Run file manager integration tests with real files"); test_manager_integration_step.dependOn(&run_test_manager_integration.step); // Test P2P Comprehensive const test_p2p_comprehensive_module = b.createModule(.{ .root_source_file = b.path("tests/test_p2p_comprehensive.zig"), .target = target, .optimize = .Debug, }); test_p2p_comprehensive_module.addImport("p2p", p2p_module); test_p2p_comprehensive_module.addImport("core", core_module); test_p2p_comprehensive_module.addImport("network", network_module); test_p2p_comprehensive_module.addImport("files", files_module); const test_p2p_comprehensive = b.addTest(.{ .root_module = test_p2p_comprehensive_module, }); const run_test_p2p_comprehensive = b.addRunArtifact(test_p2p_comprehensive); const test_p2p_comprehensive_step = b.step("test-p2p-comprehensive", "Run P2P comprehensive tests"); test_p2p_comprehensive_step.dependOn(&run_test_p2p_comprehensive.step); // Test Helpers module for shared test utilities const test_helpers_module = b.createModule(.{ .root_source_file = b.path("tests/helpers/test_p2p_pair.zig"), .target = target, .optimize = .Debug, }); test_helpers_module.addImport("p2p", p2p_module); test_helpers_module.addImport("core", core_module); test_helpers_module.addImport("network", network_module); // Test P2P Coverage - Comprehensive coverage tests for p2p.zig const test_p2p_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/test_p2p_coverage.zig"), .target = target, .optimize = .Debug, }); test_p2p_coverage_module.addImport("p2p", p2p_module); test_p2p_coverage_module.addImport("core", core_module); test_p2p_coverage_module.addImport("network", network_module); test_p2p_coverage_module.addImport("files", files_module); test_p2p_coverage_module.addImport("helpers", test_helpers_module); const test_p2p_coverage = b.addTest(.{ .root_module = test_p2p_coverage_module, }); const run_test_p2p_coverage = b.addRunArtifact(test_p2p_coverage); const test_p2p_coverage_step = b.step("test-p2p-coverage", "Run P2P coverage tests"); test_p2p_coverage_step.dependOn(&run_test_p2p_coverage.step); // Test P2P High Impact - Real I/O and critical paths const test_p2p_high_impact_module = b.createModule(.{ .root_source_file = b.path("tests/test_p2p_high_impact.zig"), .target = target, .optimize = .Debug, }); test_p2p_high_impact_module.addImport("p2p", p2p_module); test_p2p_high_impact_module.addImport("core", core_module); test_p2p_high_impact_module.addImport("network", network_module); test_p2p_high_impact_module.addImport("files", files_module); const test_p2p_high_impact = b.addTest(.{ .root_module = test_p2p_high_impact_module, }); const run_test_p2p_high_impact = b.addRunArtifact(test_p2p_high_impact); const test_p2p_high_impact_step = b.step("test-p2p-high-impact", "Run P2P high-impact tests with real I/O"); test_p2p_high_impact_step.dependOn(&run_test_p2p_high_impact.step); // Test Connected Coverage - Integration tests using TestP2PPair const test_connected_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_connected_coverage.zig"), .target = target, .optimize = .Debug, }); test_connected_coverage_module.addImport("p2p", p2p_module); test_connected_coverage_module.addImport("core", core_module); test_connected_coverage_module.addImport("network", network_module); test_connected_coverage_module.addImport("files", files_module); test_connected_coverage_module.addImport("helpers", test_helpers_module); const test_connected_coverage = b.addTest(.{ .root_module = test_connected_coverage_module, }); const run_test_connected_coverage = b.addRunArtifact(test_connected_coverage); const test_connected_coverage_step = b.step("test-connected-coverage", "Run connected peer coverage tests"); test_connected_coverage_step.dependOn(&run_test_connected_coverage.step); // Test Tier1 Coverage - P2P state, key pinning, memory limits, session management const test_tier1_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_tier1_coverage.zig"), .target = target, .optimize = .Debug, }); test_tier1_coverage_module.addImport("p2p", p2p_module); test_tier1_coverage_module.addImport("core", core_module); test_tier1_coverage_module.addImport("network", network_module); test_tier1_coverage_module.addImport("files", files_module); const test_tier1_coverage = b.addTest(.{ .root_module = test_tier1_coverage_module, }); const run_test_tier1_coverage = b.addRunArtifact(test_tier1_coverage); const test_tier1_coverage_step = b.step("test-tier1-coverage", "Run Tier 1 coverage tests"); test_tier1_coverage_step.dependOn(&run_test_tier1_coverage.step); // Test Tier 2 Coverage - Additional isolated function tests const test_tier2_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_tier2_coverage.zig"), .target = target, .optimize = .Debug, }); test_tier2_coverage_module.addImport("core", core_module); test_tier2_coverage_module.addImport("network", network_module); test_tier2_coverage_module.addImport("files", files_module); const test_tier2_coverage = b.addTest(.{ .root_module = test_tier2_coverage_module, }); const run_test_tier2_coverage = b.addRunArtifact(test_tier2_coverage); const test_tier2_coverage_step = b.step("test-tier2-coverage", "Run Tier 2 coverage tests"); test_tier2_coverage_step.dependOn(&run_test_tier2_coverage.step); // Test Tier 3 Coverage - Manager session workflow tests with mock metadata const test_tier3_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_tier3_coverage.zig"), .target = target, .optimize = .Debug, }); test_tier3_coverage_module.addImport("core", core_module); test_tier3_coverage_module.addImport("network", network_module); test_tier3_coverage_module.addImport("files", files_module); const test_tier3_coverage = b.addTest(.{ .root_module = test_tier3_coverage_module, }); const run_test_tier3_coverage = b.addRunArtifact(test_tier3_coverage); const test_tier3_coverage_step = b.step("test-tier3-coverage", "Run Tier 3 coverage tests"); test_tier3_coverage_step.dependOn(&run_test_tier3_coverage.step); // Test Address Coverage - Address parsing and validation tests const test_address_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/core/test_address.zig"), .target = target, .optimize = .Debug, }); test_address_coverage_module.addImport("core", core_module); const test_address_coverage = b.addTest(.{ .root_module = test_address_coverage_module, }); const run_test_address_coverage = b.addRunArtifact(test_address_coverage); const test_address_coverage_step = b.step("test-address-coverage", "Run address coverage tests"); test_address_coverage_step.dependOn(&run_test_address_coverage.step); // Test Transfer Coverage - Targeted transfer.zig tests const test_transfer_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_transfer_coverage.zig"), .target = target, .optimize = .Debug, }); test_transfer_coverage_module.addImport("files", files_module); test_transfer_coverage_module.addImport("core", core_module); const test_transfer_coverage = b.addTest(.{ .root_module = test_transfer_coverage_module, }); const run_test_transfer_coverage = b.addRunArtifact(test_transfer_coverage); const test_transfer_coverage_step = b.step("test-transfer-coverage", "Run transfer coverage tests"); test_transfer_coverage_step.dependOn(&run_test_transfer_coverage.step); // Test NAT Coverage - NAT traversal tests with mock STUN/TURN servers const test_nat_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_nat_coverage.zig"), .target = target, .optimize = .Debug, }); test_nat_coverage_module.addImport("network", network_module); test_nat_coverage_module.addImport("core", core_module); test_nat_coverage_module.addImport("helpers", test_helpers_module); const test_nat_coverage = b.addTest(.{ .root_module = test_nat_coverage_module, }); const run_test_nat_coverage = b.addRunArtifact(test_nat_coverage); const test_nat_coverage_step = b.step("test-nat-coverage", "Run NAT coverage tests with mock servers"); test_nat_coverage_step.dependOn(&run_test_nat_coverage.step); // Test TURN Coverage - TURN integration tests const test_turn_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_turn_coverage.zig"), .target = target, .optimize = .Debug, }); test_turn_coverage_module.addImport("network", network_module); test_turn_coverage_module.addImport("core", core_module); const test_turn_coverage = b.addTest(.{ .root_module = test_turn_coverage_module, }); const run_test_turn_coverage = b.addRunArtifact(test_turn_coverage); const test_turn_coverage_step = b.step("test-turn-coverage", "Run TURN integration coverage tests"); test_turn_coverage_step.dependOn(&run_test_turn_coverage.step); // Test Discovery Coverage - Discovery message encoding/decoding tests const test_discovery_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_discovery_coverage.zig"), .target = target, .optimize = .Debug, }); test_discovery_coverage_module.addImport("network", network_module); test_discovery_coverage_module.addImport("core", core_module); const test_discovery_coverage = b.addTest(.{ .root_module = test_discovery_coverage_module, }); const run_test_discovery_coverage = b.addRunArtifact(test_discovery_coverage); const test_discovery_coverage_step = b.step("test-discovery-coverage", "Run discovery coverage tests"); test_discovery_coverage_step.dependOn(&run_test_discovery_coverage.step); // Test Manager Coverage - FileSharingManager tests const test_manager_coverage_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_manager_coverage.zig"), .target = target, .optimize = .Debug, }); test_manager_coverage_module.addImport("files", files_module); test_manager_coverage_module.addImport("core", core_module); const test_manager_coverage = b.addTest(.{ .root_module = test_manager_coverage_module, }); const run_test_manager_coverage = b.addRunArtifact(test_manager_coverage); const test_manager_coverage_step = b.step("test-manager-coverage", "Run manager coverage tests"); test_manager_coverage_step.dependOn(&run_test_manager_coverage.step); // Test Manager Sessions - FileSharingManager session tests with real files const test_manager_sessions_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_manager_sessions.zig"), .target = target, .optimize = .Debug, }); test_manager_sessions_module.addImport("files", files_module); test_manager_sessions_module.addImport("core", core_module); const test_manager_sessions = b.addTest(.{ .root_module = test_manager_sessions_module, }); const run_test_manager_sessions = b.addRunArtifact(test_manager_sessions); const test_manager_sessions_step = b.step("test-manager-sessions", "Run manager session tests"); test_manager_sessions_step.dependOn(&run_test_manager_sessions.step); // Test Real File I/O - Real file operations for maximum coverage const test_real_file_io_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_real_file_io.zig"), .target = target, .optimize = .Debug, }); test_real_file_io_module.addImport("p2p", p2p_module); test_real_file_io_module.addImport("core", core_module); test_real_file_io_module.addImport("network", network_module); test_real_file_io_module.addImport("files", files_module); test_real_file_io_module.addImport("helpers", test_helpers_module); const test_real_file_io = b.addTest(.{ .root_module = test_real_file_io_module, }); const run_test_real_file_io = b.addRunArtifact(test_real_file_io); const test_real_file_io_step = b.step("test-real-file-io", "Run real file I/O coverage tests"); test_real_file_io_step.dependOn(&run_test_real_file_io.step); // Test MockFS Edge Cases const test_mockfs_edge_cases_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_mockfs_edge_cases.zig"), .target = target, .optimize = .Debug, }); test_mockfs_edge_cases_module.addImport("files", files_module); test_mockfs_edge_cases_module.addImport("core", core_module); const test_mockfs_edge_cases = b.addTest(.{ .root_module = test_mockfs_edge_cases_module, }); const run_test_mockfs_edge_cases = b.addRunArtifact(test_mockfs_edge_cases); const test_mockfs_edge_cases_step = b.step("test-mockfs", "Run MockFS edge case tests"); test_mockfs_edge_cases_step.dependOn(&run_test_mockfs_edge_cases.step); // Test Full Integration - comprehensive integration tests for maximum coverage const test_full_integration_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_full_integration.zig"), .target = target, .optimize = .Debug, }); test_full_integration_module.addImport("p2p", p2p_module); test_full_integration_module.addImport("core", core_module); test_full_integration_module.addImport("network", network_module); test_full_integration_module.addImport("files", files_module); const test_full_integration = b.addTest(.{ .root_module = test_full_integration_module, }); const run_test_full_integration = b.addRunArtifact(test_full_integration); const test_full_integration_step = b.step("test-full-integration", "Run full integration coverage tests"); test_full_integration_step.dependOn(&run_test_full_integration.step); // Test Serializer Extended const test_serializer_extended_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_serializer_extended.zig"), .target = target, .optimize = .Debug, }); test_serializer_extended_module.addImport("protocol", protocol_module); const test_serializer_extended = b.addTest(.{ .root_module = test_serializer_extended_module, }); const run_test_serializer_extended = b.addRunArtifact(test_serializer_extended); const test_serializer_extended_step = b.step("test-serializer", "Run serializer extended tests"); test_serializer_extended_step.dependOn(&run_test_serializer_extended.step); // Test IP Reflection (Bundled STUN) variable-length encoding const test_ip_reflection_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_ip_reflection.zig"), .target = target, .optimize = .Debug, }); test_ip_reflection_module.addImport("protocol", protocol_module); test_ip_reflection_module.addImport("p2p", p2p_module); const test_ip_reflection = b.addTest(.{ .root_module = test_ip_reflection_module, }); const run_test_ip_reflection = b.addRunArtifact(test_ip_reflection); const test_ip_reflection_step = b.step("test-ip-reflection", "Run IP Reflection variable-length encoding tests"); test_ip_reflection_step.dependOn(&run_test_ip_reflection.step); // Test Discovery Extended const test_discovery_extended_module = b.createModule(.{ .root_source_file = b.path("tests/network/test_discovery_extended.zig"), .target = target, .optimize = .Debug, }); test_discovery_extended_module.addImport("network", network_module); test_discovery_extended_module.addImport("core", core_module); const test_discovery_extended = b.addTest(.{ .root_module = test_discovery_extended_module, }); const run_test_discovery_extended = b.addRunArtifact(test_discovery_extended); const test_discovery_extended_step = b.step("test-discovery", "Run discovery extended tests"); test_discovery_extended_step.dependOn(&run_test_discovery_extended.step); // Test NAT Extended const test_nat_extended_module = b.createModule(.{ .root_source_file = b.path("tests/network/test_nat_extended.zig"), .target = target, .optimize = .Debug, }); test_nat_extended_module.addImport("network", network_module); test_nat_extended_module.addImport("core", core_module); const test_nat_extended = b.addTest(.{ .root_module = test_nat_extended_module, }); const run_test_nat_extended = b.addRunArtifact(test_nat_extended); const test_nat_extended_step = b.step("test-nat-extended", "Run NAT extended tests"); test_nat_extended_step.dependOn(&run_test_nat_extended.step); // Test TURN Integration const test_turn_integration_module = b.createModule(.{ .root_source_file = b.path("tests/network/test_turn_integration.zig"), .target = target, .optimize = .Debug, }); test_turn_integration_module.addImport("network", network_module); test_turn_integration_module.addImport("core", core_module); const test_turn_integration = b.addTest(.{ .root_module = test_turn_integration_module, }); const run_test_turn_integration = b.addRunArtifact(test_turn_integration); const test_turn_integration_step = b.step("test-turn-integration", "Run TURN integration tests"); test_turn_integration_step.dependOn(&run_test_turn_integration.step); // Test Peer Metrics const test_peer_metrics_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_peer_metrics.zig"), .target = target, .optimize = .Debug, }); test_peer_metrics_module.addImport("files", files_module); test_peer_metrics_module.addImport("core", core_module); const test_peer_metrics = b.addTest(.{ .root_module = test_peer_metrics_module, }); const run_test_peer_metrics = b.addRunArtifact(test_peer_metrics); const test_peer_metrics_step = b.step("test-peer-metrics", "Run peer metrics tests"); test_peer_metrics_step.dependOn(&run_test_peer_metrics.step); // Test Piece Buffer Pool const test_piece_buffer_pool_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_piece_buffer_pool.zig"), .target = target, .optimize = .Debug, }); test_piece_buffer_pool_module.addImport("files", files_module); test_piece_buffer_pool_module.addImport("core", core_module); const test_piece_buffer_pool = b.addTest(.{ .root_module = test_piece_buffer_pool_module, }); const run_test_piece_buffer_pool = b.addRunArtifact(test_piece_buffer_pool); const test_piece_buffer_pool_step = b.step("test-piece-buffer-pool", "Run piece buffer pool tests"); test_piece_buffer_pool_step.dependOn(&run_test_piece_buffer_pool.step); // Test Verification Pool const test_verification_pool_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_verification_pool.zig"), .target = target, .optimize = .Debug, }); test_verification_pool_module.addImport("files", files_module); test_verification_pool_module.addImport("core", core_module); const test_verification_pool = b.addTest(.{ .root_module = test_verification_pool_module, }); const run_test_verification_pool = b.addRunArtifact(test_verification_pool); const test_verification_pool_step = b.step("test-verification-pool", "Run verification pool tests"); test_verification_pool_step.dependOn(&run_test_verification_pool.step); // Test Piece Pipeline const test_piece_pipeline_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_piece_pipeline.zig"), .target = target, .optimize = .Debug, }); test_piece_pipeline_module.addImport("files", files_module); test_piece_pipeline_module.addImport("core", core_module); const test_piece_pipeline = b.addTest(.{ .root_module = test_piece_pipeline_module, }); const run_test_piece_pipeline = b.addRunArtifact(test_piece_pipeline); const test_piece_pipeline_step = b.step("test-piece-pipeline", "Run piece pipeline tests"); test_piece_pipeline_step.dependOn(&run_test_piece_pipeline.step); // ============================================================ // Individual Files Module Source Tests (inline tests) // ============================================================ // Test files/download.zig inline tests const test_download_src_module = b.createModule(.{ .root_source_file = b.path("src/files/download.zig"), .target = target, .optimize = .Debug, }); test_download_src_module.addImport("core", core_module); test_download_src_module.addImport("protocol", protocol_module); const test_download_src = b.addTest(.{ .root_module = test_download_src_module, }); const run_test_download_src = b.addRunArtifact(test_download_src); const test_download_src_step = b.step("test-download-src", "Run download.zig inline tests"); test_download_src_step.dependOn(&run_test_download_src.step); // Test files/transfer.zig inline tests const test_transfer_src_module = b.createModule(.{ .root_source_file = b.path("src/files/transfer.zig"), .target = target, .optimize = .Debug, }); test_transfer_src_module.addImport("core", core_module); test_transfer_src_module.addImport("protocol", protocol_module); const test_transfer_src = b.addTest(.{ .root_module = test_transfer_src_module, }); const run_test_transfer_src = b.addRunArtifact(test_transfer_src); const test_transfer_src_step = b.step("test-transfer-src", "Run transfer.zig inline tests"); test_transfer_src_step.dependOn(&run_test_transfer_src.step); // Test files/file.zig inline tests const test_file_src_module = b.createModule(.{ .root_source_file = b.path("src/files/file.zig"), .target = target, .optimize = .Debug, }); test_file_src_module.addImport("core", core_module); const test_file_src = b.addTest(.{ .root_module = test_file_src_module, }); const run_test_file_src = b.addRunArtifact(test_file_src); const test_file_src_step = b.step("test-file-src", "Run file.zig inline tests"); test_file_src_step.dependOn(&run_test_file_src.step); // Test files/path_security.zig inline tests const test_path_security_src_module = b.createModule(.{ .root_source_file = b.path("src/files/path_security.zig"), .target = target, .optimize = .Debug, }); test_path_security_src_module.addImport("core", core_module); const test_path_security_src = b.addTest(.{ .root_module = test_path_security_src_module, }); const run_test_path_security_src = b.addRunArtifact(test_path_security_src); const test_path_security_src_step = b.step("test-path-security-src", "Run path_security.zig inline tests"); test_path_security_src_step.dependOn(&run_test_path_security_src.step); // Test files/piece.zig inline tests const test_piece_src_module = b.createModule(.{ .root_source_file = b.path("src/files/piece.zig"), .target = target, .optimize = .Debug, }); test_piece_src_module.addImport("core", core_module); const test_piece_src = b.addTest(.{ .root_module = test_piece_src_module, }); const run_test_piece_src = b.addRunArtifact(test_piece_src); const test_piece_src_step = b.step("test-piece-src", "Run piece.zig inline tests"); test_piece_src_step.dependOn(&run_test_piece_src.step); // Test files/hash.zig inline tests const test_hash_src_module = b.createModule(.{ .root_source_file = b.path("src/files/hash.zig"), .target = target, .optimize = .Debug, }); test_hash_src_module.addImport("core", core_module); const test_hash_src = b.addTest(.{ .root_module = test_hash_src_module, }); const run_test_hash_src = b.addRunArtifact(test_hash_src); const test_hash_src_step = b.step("test-hash-src", "Run hash.zig inline tests"); test_hash_src_step.dependOn(&run_test_hash_src.step); // Test files/mock_fs.zig inline tests const test_mockfs_src_module = b.createModule(.{ .root_source_file = b.path("src/files/mock_fs.zig"), .target = target, .optimize = .Debug, }); test_mockfs_src_module.addImport("core", core_module); const test_mockfs_src = b.addTest(.{ .root_module = test_mockfs_src_module, }); const run_test_mockfs_src = b.addRunArtifact(test_mockfs_src); const test_mockfs_src_step = b.step("test-mockfs-src", "Run mock_fs.zig inline tests"); test_mockfs_src_step.dependOn(&run_test_mockfs_src.step); // Test files/filesystem.zig inline tests const test_filesystem_src_module = b.createModule(.{ .root_source_file = b.path("src/files/filesystem.zig"), .target = target, .optimize = .Debug, }); test_filesystem_src_module.addImport("core", core_module); const test_filesystem_src = b.addTest(.{ .root_module = test_filesystem_src_module, }); const run_test_filesystem_src = b.addRunArtifact(test_filesystem_src); const test_filesystem_src_step = b.step("test-filesystem-src", "Run filesystem.zig inline tests"); test_filesystem_src_step.dependOn(&run_test_filesystem_src.step); // Test files/adaptive_concurrency.zig inline tests const test_adaptive_src_module = b.createModule(.{ .root_source_file = b.path("src/files/adaptive_concurrency.zig"), .target = target, .optimize = .Debug, }); const test_adaptive_src = b.addTest(.{ .root_module = test_adaptive_src_module, }); const run_test_adaptive_src = b.addRunArtifact(test_adaptive_src); const test_adaptive_src_step = b.step("test-adaptive-src", "Run adaptive_concurrency.zig inline tests"); test_adaptive_src_step.dependOn(&run_test_adaptive_src.step); // Test core/limits.zig inline tests const test_limits_src_module = b.createModule(.{ .root_source_file = b.path("src/core/limits.zig"), .target = target, .optimize = .Debug, }); const test_limits_src = b.addTest(.{ .root_module = test_limits_src_module, }); const run_test_limits_src = b.addRunArtifact(test_limits_src); const test_limits_src_step = b.step("test-limits-src", "Run limits.zig inline tests"); test_limits_src_step.dependOn(&run_test_limits_src.step); // Test files/upload.zig inline tests const test_upload_src_module = b.createModule(.{ .root_source_file = b.path("src/files/upload.zig"), .target = target, .optimize = .Debug, }); test_upload_src_module.addImport("core", core_module); test_upload_src_module.addImport("protocol", protocol_module); const test_upload_src = b.addTest(.{ .root_module = test_upload_src_module, }); const run_test_upload_src = b.addRunArtifact(test_upload_src); const test_upload_src_step = b.step("test-upload-src", "Run upload.zig inline tests"); test_upload_src_step.dependOn(&run_test_upload_src.step); // Test network/discovery.zig inline tests const test_discovery_src_module = b.createModule(.{ .root_source_file = b.path("src/network/discovery.zig"), .target = target, .optimize = .Debug, }); test_discovery_src_module.addImport("core", core_module); const test_discovery_src = b.addTest(.{ .root_module = test_discovery_src_module, }); const run_test_discovery_src = b.addRunArtifact(test_discovery_src); const test_discovery_src_step = b.step("test-discovery-src", "Run discovery.zig inline tests"); test_discovery_src_step.dependOn(&run_test_discovery_src.step); // Test files/manager.zig inline tests (93 tests) const test_manager_src_module = b.createModule(.{ .root_source_file = b.path("src/files/manager.zig"), .target = target, .optimize = .Debug, }); test_manager_src_module.addImport("core", core_module); test_manager_src_module.addImport("protocol", protocol_module); const test_manager_src = b.addTest(.{ .root_module = test_manager_src_module, }); const run_test_manager_src = b.addRunArtifact(test_manager_src); const test_manager_src_step = b.step("test-manager-src", "Run manager.zig inline tests"); test_manager_src_step.dependOn(&run_test_manager_src.step); // Test network/nat.zig inline tests (33 tests) const test_nat_src_module = b.createModule(.{ .root_source_file = b.path("src/network/nat.zig"), .target = target, .optimize = .Debug, }); test_nat_src_module.addImport("core", core_module); const test_nat_src = b.addTest(.{ .root_module = test_nat_src_module, }); const run_test_nat_src = b.addRunArtifact(test_nat_src); const test_nat_src_step = b.step("test-nat-src", "Run nat.zig inline tests"); test_nat_src_step.dependOn(&run_test_nat_src.step); // Test network/routing.zig inline tests const test_routing_src_module = b.createModule(.{ .root_source_file = b.path("src/network/routing.zig"), .target = target, .optimize = .Debug, }); test_routing_src_module.addImport("core", core_module); const test_routing_src = b.addTest(.{ .root_module = test_routing_src_module, }); const run_test_routing_src = b.addRunArtifact(test_routing_src); const test_routing_src_step = b.step("test-routing-src", "Run routing.zig inline tests"); test_routing_src_step.dependOn(&run_test_routing_src.step); // Test protocol/serializer.zig inline tests (28 tests) const test_serializer_src_module = b.createModule(.{ .root_source_file = b.path("src/protocol/serializer.zig"), .target = target, .optimize = .Debug, }); test_serializer_src_module.addImport("core", core_module); const test_serializer_src = b.addTest(.{ .root_module = test_serializer_src_module, }); const run_test_serializer_src = b.addRunArtifact(test_serializer_src); const test_serializer_src_step = b.step("test-serializer-src", "Run serializer.zig inline tests"); test_serializer_src_step.dependOn(&run_test_serializer_src.step); // Test network/dht.zig inline tests (21 tests) const test_dht_src_module = b.createModule(.{ .root_source_file = b.path("src/network/dht.zig"), .target = target, .optimize = .Debug, }); test_dht_src_module.addImport("core", core_module); const test_dht_src = b.addTest(.{ .root_module = test_dht_src_module, }); const run_test_dht_src = b.addRunArtifact(test_dht_src); const test_dht_src_step = b.step("test-dht-src", "Run dht.zig inline tests"); test_dht_src_step.dependOn(&run_test_dht_src.step); // Test Memory Leaks const test_memory_leaks_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_memory_leaks.zig"), .target = target, .optimize = .Debug, }); test_memory_leaks_module.addImport("core", core_module); test_memory_leaks_module.addImport("network", network_module); test_memory_leaks_module.addImport("protocol", protocol_module); test_memory_leaks_module.addImport("files", files_module); test_memory_leaks_module.addImport("p2p", p2p_module); const test_memory_leaks = b.addTest(.{ .root_module = test_memory_leaks_module, }); const run_test_memory_leaks = b.addRunArtifact(test_memory_leaks); const test_memory_leaks_step = b.step("test-memory-leaks", "Run comprehensive memory leak tests"); test_memory_leaks_step.dependOn(&run_test_memory_leaks.step); // Test Memory Safety (use-after-free, reference counting, etc.) const test_memory_safety_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_memory_safety.zig"), .target = target, .optimize = .Debug, }); test_memory_safety_module.addImport("core", core_module); test_memory_safety_module.addImport("network", network_module); test_memory_safety_module.addImport("protocol", protocol_module); test_memory_safety_module.addImport("files", files_module); const test_memory_safety = b.addTest(.{ .root_module = test_memory_safety_module, }); const run_test_memory_safety = b.addRunArtifact(test_memory_safety); const test_memory_safety_step = b.step("test-memory-safety", "Run use-after-free and reference counting tests"); test_memory_safety_step.dependOn(&run_test_memory_safety.step); // Test Thread Safety const test_thread_safety_module = b.createModule(.{ .root_source_file = b.path("tests/core/test_thread_safety.zig"), .target = target, .optimize = .Debug, }); test_thread_safety_module.addImport("core", core_module); const test_thread_safety = b.addTest(.{ .root_module = test_thread_safety_module, }); const run_test_thread_safety = b.addRunArtifact(test_thread_safety); const test_thread_safety_step = b.step("test-thread-safety", "Run thread safety tests for core module"); test_thread_safety_step.dependOn(&run_test_thread_safety.step); // Test Disk and Stubs const test_disk_and_stubs_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_disk_and_stubs.zig"), .target = target, .optimize = .Debug, }); test_disk_and_stubs_module.addImport("core", core_module); test_disk_and_stubs_module.addImport("network", network_module); test_disk_and_stubs_module.addImport("protocol", protocol_module); test_disk_and_stubs_module.addImport("files", files_module); const test_disk_and_stubs = b.addTest(.{ .root_module = test_disk_and_stubs_module, }); const run_test_disk_and_stubs = b.addRunArtifact(test_disk_and_stubs); const test_disk_and_stubs_step = b.step("test-disk-stubs", "Run disk space and stub implementation tests"); test_disk_and_stubs_step.dependOn(&run_test_disk_and_stubs.step); // ============================================================ // Production Readiness Tests // ============================================================ // Test Nonce Exhaustion const test_nonce_exhaustion_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_nonce_exhaustion.zig"), .target = target, .optimize = .Debug, }); test_nonce_exhaustion_module.addImport("protocol", protocol_module); const test_nonce_exhaustion = b.addTest(.{ .root_module = test_nonce_exhaustion_module, }); const run_test_nonce_exhaustion = b.addRunArtifact(test_nonce_exhaustion); const test_nonce_exhaustion_step = b.step("test-nonce-exhaustion", "Run nonce exhaustion and key rotation tests"); test_nonce_exhaustion_step.dependOn(&run_test_nonce_exhaustion.step); // Test Allocation Limits const test_allocation_limits_module = b.createModule(.{ .root_source_file = b.path("tests/protocol/test_allocation_limits.zig"), .target = target, .optimize = .Debug, }); test_allocation_limits_module.addImport("protocol", protocol_module); const test_allocation_limits = b.addTest(.{ .root_module = test_allocation_limits_module, }); const run_test_allocation_limits = b.addRunArtifact(test_allocation_limits); const test_allocation_limits_step = b.step("test-allocation-limits", "Run allocation limits and size validation tests"); test_allocation_limits_step.dependOn(&run_test_allocation_limits.step); // Test Download Retry const test_download_retry_module = b.createModule(.{ .root_source_file = b.path("tests/files/test_download_retry.zig"), .target = target, .optimize = .Debug, }); test_download_retry_module.addImport("files", files_module); const test_download_retry = b.addTest(.{ .root_module = test_download_retry_module, }); const run_test_download_retry = b.addRunArtifact(test_download_retry); const test_download_retry_step = b.step("test-download-retry", "Run download retry and exponential backoff tests"); test_download_retry_step.dependOn(&run_test_download_retry.step); // ============================================================ // Unit Tests for Source Files // ============================================================ // Test P2P module const test_p2p_module = b.createModule(.{ .root_source_file = b.path("src/p2p.zig"), .target = target, .optimize = .Debug, }); test_p2p_module.addImport("core", core_module); test_p2p_module.addImport("network", network_module); test_p2p_module.addImport("protocol", protocol_module); test_p2p_module.addImport("files", files_module); test_p2p_module.addImport("noise", noise_module); const test_p2p = b.addTest(.{ .root_module = test_p2p_module, }); const run_test_p2p = b.addRunArtifact(test_p2p); const test_p2p_step = b.step("test-p2p-src", "Run P2P source tests"); test_p2p_step.dependOn(&run_test_p2p.step); // Test Core module const test_core_module = b.createModule(.{ .root_source_file = b.path("src/core.zig"), .target = target, .optimize = .Debug, }); const test_core = b.addTest(.{ .root_module = test_core_module, }); const run_test_core = b.addRunArtifact(test_core); const test_core_step = b.step("test-core-src", "Run Core source tests"); test_core_step.dependOn(&run_test_core.step); // Test Network module const test_network_module = b.createModule(.{ .root_source_file = b.path("src/network.zig"), .target = target, .optimize = .Debug, }); test_network_module.addImport("core", core_module); test_network_module.addImport("noise", noise_module); const test_network = b.addTest(.{ .root_module = test_network_module, }); const run_test_network = b.addRunArtifact(test_network); const test_network_step = b.step("test-network-src", "Run Network source tests"); test_network_step.dependOn(&run_test_network.step); // Test Protocol module const test_protocol_module = b.createModule(.{ .root_source_file = b.path("src/protocol.zig"), .target = target, .optimize = .Debug, }); test_protocol_module.addImport("core", core_module); test_protocol_module.addImport("network", network_module); const test_protocol = b.addTest(.{ .root_module = test_protocol_module, }); const run_test_protocol = b.addRunArtifact(test_protocol); const test_protocol_step = b.step("test-protocol-src", "Run Protocol source tests"); test_protocol_step.dependOn(&run_test_protocol.step); // Test Files module const test_files_module = b.createModule(.{ .root_source_file = b.path("src/files.zig"), .target = target, .optimize = .Debug, }); test_files_module.addImport("core", core_module); test_files_module.addImport("protocol", protocol_module); const test_files = b.addTest(.{ .root_module = test_files_module, }); const run_test_files = b.addRunArtifact(test_files); const test_files_step = b.step("test-files-src", "Run Files source tests"); test_files_step.dependOn(&run_test_files.step); // Test Noise module const test_noise_module = b.createModule(.{ .root_source_file = b.path("src/noise/noise.zig"), .target = target, .optimize = .Debug, }); const test_noise = b.addTest(.{ .root_module = test_noise_module, }); const run_test_noise = b.addRunArtifact(test_noise); const test_noise_step = b.step("test-noise-src", "Run Noise source tests"); test_noise_step.dependOn(&run_test_noise.step); // All source tests step const test_all_src_step = b.step("test-src", "Run all source tests"); test_all_src_step.dependOn(test_core_step); test_all_src_step.dependOn(test_network_step); test_all_src_step.dependOn(test_protocol_step); test_all_src_step.dependOn(test_files_step); test_all_src_step.dependOn(test_p2p_step); test_all_src_step.dependOn(test_noise_step); // Test security fixes const test_security_fixes_module = b.createModule(.{ .root_source_file = b.path("tests/security/test_security_fixes.zig"), .target = target, .optimize = .Debug, }); test_security_fixes_module.addImport("core", core_module); test_security_fixes_module.addImport("network", network_module); const test_security_fixes = b.addTest(.{ .root_module = test_security_fixes_module, }); const run_test_security_fixes = b.addRunArtifact(test_security_fixes); const test_security_fixes_step = b.step("test-security-fixes", "Run security fixes tests"); test_security_fixes_step.dependOn(&run_test_security_fixes.step); // Test MWP Connection - MWP hole punch integration test with two P2P nodes const test_mwp_connection_module = b.createModule(.{ .root_source_file = b.path("tests/integration/test_mwp_connection.zig"), .target = target, .optimize = .Debug, }); test_mwp_connection_module.addImport("p2p", p2p_module); test_mwp_connection_module.addImport("core", core_module); test_mwp_connection_module.addImport("network", network_module); test_mwp_connection_module.addImport("mwp", mwp_module); test_mwp_connection_module.addImport("mwp_lib", mwp_lib_module); test_mwp_connection_module.addImport("helpers", test_helpers_module); const test_mwp_connection = b.addTest(.{ .root_module = test_mwp_connection_module, }); const run_test_mwp_connection = b.addRunArtifact(test_mwp_connection); const test_mwp_step = b.step("test-mwp", "Run MWP hole punch integration test"); test_mwp_step.dependOn(&run_test_mwp_connection.step); // All integration tests step const test_all_integration_step = b.step("test-integration", "Run all integration tests"); test_all_integration_step.dependOn(test_network_manager_step); test_all_integration_step.dependOn(test_bridge_step); test_all_integration_step.dependOn(test_security_step); test_all_integration_step.dependOn(test_message_auth_step); test_all_integration_step.dependOn(test_encryption_integration_step); test_all_integration_step.dependOn(test_error_recovery_step); test_all_integration_step.dependOn(test_e2e_step); test_all_integration_step.dependOn(test_memory_leaks_step); test_all_integration_step.dependOn(test_memory_safety_step); test_all_integration_step.dependOn(test_disk_and_stubs_step); test_all_integration_step.dependOn(test_nonce_exhaustion_step); test_all_integration_step.dependOn(test_allocation_limits_step); test_all_integration_step.dependOn(test_download_retry_step); test_all_integration_step.dependOn(test_security_fixes_step); test_all_integration_step.dependOn(test_noise_connection_step); test_all_integration_step.dependOn(test_secure_connection_step); test_all_integration_step.dependOn(test_nat_step); test_all_integration_step.dependOn(test_replay_protection_step); test_all_integration_step.dependOn(test_replay_integration_step); test_all_integration_step.dependOn(test_transfer_protocol_step); test_all_integration_step.dependOn(test_upload_step); test_all_integration_step.dependOn(test_manager_step); test_all_integration_step.dependOn(test_manager_integration_step); test_all_integration_step.dependOn(test_p2p_comprehensive_step); test_all_integration_step.dependOn(test_p2p_coverage_step); test_all_integration_step.dependOn(test_serializer_extended_step); test_all_integration_step.dependOn(test_discovery_extended_step); test_all_integration_step.dependOn(test_nat_extended_step); test_all_integration_step.dependOn(test_turn_integration_step); test_all_integration_step.dependOn(test_peer_metrics_step); test_all_integration_step.dependOn(test_piece_buffer_pool_step); test_all_integration_step.dependOn(test_verification_pool_step); test_all_integration_step.dependOn(test_piece_pipeline_step); test_all_integration_step.dependOn(test_real_file_io_step); test_all_integration_step.dependOn(test_mwp_step); test_all_integration_step.dependOn(test_real_e2e_step); // ============================================================ // Main Test Target // ============================================================ const test_step = b.step("test", "Run all tests"); test_step.dependOn(test_all_src_step); test_step.dependOn(test_all_integration_step); // ============================================================ // Check Step (compile check) // ============================================================ const check_module = b.createModule(.{ .root_source_file = b.path("src/p2p.zig"), .target = target, .optimize = optimize, }); check_module.addImport("core", core_module); check_module.addImport("network", network_module); check_module.addImport("protocol", protocol_module); check_module.addImport("files", files_module); check_module.addImport("noise", noise_module); check_module.addImport("p2p", p2p_module); check_module.addImport("mwp", mwp_module); check_module.addImport("mwp_lib", mwp_lib_module); const check_exe = b.addExecutable(.{ .name = "p2p-check", .root_module = check_module, }); const check_step = b.step("check", "Check for compilation errors"); check_step.dependOn(&check_exe.step); // ============================================================ // Documentation Generation // ============================================================ const docs_module = b.createModule(.{ .root_source_file = b.path("src/p2p.zig"), .target = target, .optimize = optimize, }); docs_module.addImport("core", core_module); docs_module.addImport("network", network_module); docs_module.addImport("protocol", protocol_module); docs_module.addImport("files", files_module); docs_module.addImport("noise", noise_module); const docs_lib = b.addLibrary(.{ .name = "p2p", .root_module = docs_module, }); const install_docs = b.addInstallDirectory(.{ .source_dir = docs_lib.getEmittedDocs(), .install_dir = .{ .custom = "../docs" }, .install_subdir = "", }); const docs_step = b.step("docs", "Generate API documentation"); docs_step.dependOn(&install_docs.step); // ============================================================ // Clean step (informational only) // ============================================================ const clean_step = b.step("clean", "Remove build artifacts (use: rm -rf zig-out .zig-cache)"); _ = clean_step; }