authorgravatar for suirad@users.noreply.github.comSuirad <suirad@users.noreply.github.com> 2018-11-24 17:29:06-06:00
committergravatar for suirad@users.noreply.github.comSuirad <suirad@users.noreply.github.com> 2018-11-30 02:08:34-06:00
log0abd5520bdc8118369895f67f581d10c847ac139
treeab9c925b622fa96295e8d5607597b35e596be295
parent5dfca87a65884f8564a8c8e2444bb906073425f3

Platform specific tests


1 files changed, 20 insertions(+), 7 deletions(-)

std/os/index.zig+20-7
...@@ -775,15 +775,26 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {...@@ -775,15 +775,26 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
775775
776test "os.getEnvMap" {776test "os.getEnvMap" {
777 var env = try getEnvMap(std.debug.global_allocator);777 var env = try getEnvMap(std.debug.global_allocator);
778 var seen_path = false;778 var seen_home = false;
779 var it = env.iterator();779 var it = env.iterator();
780 while (it.next()) |pair| {780 while (it.next()) |pair| {
781 if (mem.eql(u8, pair.key, "PATH")) {781 switch (builtin.os){
782 seen_path = true;782 builtin.Os.windows => {
783 }783 if (mem.eql(u8, pair.key, "HOMEPATH")) {
784 seen_home = true;
785 }
786 },
787 builtin.Os.linux, builtin.Os.macosx,
788 builtin.Os.ios => {
789 if (mem.eql(u8, pair.key, "HOME")) {
790 seen_home = true;
791 }
792 },
793 else => @compileError("unimplemented"),
794 }
784 }795 }
785796
786 assert(seen_path == true);797 assert(seen_home == true);
787}798}
788799
789/// TODO make this go through libc when we have it800/// TODO make this go through libc when we have it
...@@ -854,8 +865,10 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned...@@ -854,8 +865,10 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned
854865
855test "os.getEnvVarOwned" {866test "os.getEnvVarOwned" {
856 switch (builtin.os) {867 switch (builtin.os) {
857 builtin.Os.windows, builtin.Os.linux, builtin.Os.macosx,868 builtin.Os.windows => _ = try getEnvVarOwned(debug.global_allocator, "HOMEPATH"),
858 builtin.Os.ios => _ = try getEnvVarOwned(debug.global_allocator, "PATH"),869
870 builtin.Os.linux, builtin.Os.macosx,
871 builtin.Os.ios => _ = try getEnvVarOwned(debug.global_allocator, "HOME"),
859 else => @compileError("unimplemented"),872 else => @compileError("unimplemented"),
860 }873 }
861}874}