aboutsummaryrefslogtreecommitdiff
path: root/lib/std/testing.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-04-28 11:20:53 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-04-28 11:20:53 -0700
commit3052597a734f87727fa7f1a0e92247f100df3e96 (patch)
tree5ad90f9006fe13801ca5f5c832d7dec957df88ad /lib/std/testing.zig
parent9181c98225dccbe698efafffd9a7bc6f50b8b46d (diff)
downloadzig-3052597a734f87727fa7f1a0e92247f100df3e96.tar.gz
zig-3052597a734f87727fa7f1a0e92247f100df3e96.zip
Revert "std.testing: add writeZigFile for TmpDir"
This reverts commit 7f13f5cd5f5a518638b15d7225eae2d88ec1efb5. I'd like to review this one before it goes in. This is an awfully specific API that I don't think belongs in std.testing. Also I don't want any code snippets in doc strings. We have doctests for that.
Diffstat (limited to 'lib/std/testing.zig')
-rw-r--r--lib/std/testing.zig37
1 files changed, 0 insertions, 37 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
index b90fbc2e4f..016e84acd8 100644
--- a/lib/std/testing.zig
+++ b/lib/std/testing.zig
@@ -374,43 +374,6 @@ pub const TmpDir = struct {
self.parent_dir.close();
self.* = undefined;
}
-
- /// Writes program string as zig file into tmp directory
- /// Caller owns memory
- ///
- /// ```
- /// const progstr = "pub fn main() void {}\n";
- /// var it = try std.process.argsWithAllocator(std.testing.allocator);
- /// defer it.deinit(); // no-op unless WASI or Windows
- /// const testargs = try std.testing.getTestArgs(&it);
- /// var tmp = std.testing.tmpDir(.{ .no_follow = true }); // ie zig-cache/tmp/8DLgoSEqz593PAEE
- /// defer tmp.cleanup();
- /// const zigfile_path = try tmp.writeZigFile(std.testing.allocator, progstr, "bruh");
- /// defer std.testing.allocator.free(zigfile_path);
- /// const binary = zigfile_path[0 .. zigfile_path.len - 4]; // '.zig' is 4 characters
- /// try std.testing.buildExe(testargs.zigexec, zigfile_path, binary);
- /// ```
- pub fn writeZigFile(
- self: *TmpDir,
- alloc: std.mem.Allocator,
- progstr: []const u8,
- filename: []const u8,
- ) ![]const u8 {
- const tmpdir_path = try self.getFullPath(alloc);
- defer alloc.free(tmpdir_path);
- const suffix_zig = ".zig";
- const zigfile_path = try std.mem.concat(alloc, u8, &[_][]const u8{
- tmpdir_path,
- std.fs.path.sep_str,
- filename,
- suffix_zig,
- });
- errdefer alloc.free(zigfile_path);
- const zigfile = try std.mem.concat(alloc, u8, &[_][]const u8{ filename, suffix_zig });
- defer alloc.free(zigfile);
- try self.dir.writeFile(zigfile, progstr);
- return zigfile_path;
- }
};
fn getCwdOrWasiPreopen() std.fs.Dir {