import dshould; auto cdir = std.file.getcwd; Path root = createTempPath(); scope(exit) { std.file.chdir(cdir); root.remove(); } std.file.getcwd.should.not.equal(root._path); root.chdir; std.file.getcwd.should.equal(root._path); version(Posix) { // Prepare test dir in user's home directory Path home_tmp = createTempPath("~", "tmp-d-test"); scope(exit) home_tmp.remove(); string tmp_dir_name = home_tmp.baseName; std.file.getcwd.should.not.equal(home_tmp._path); // Change current working directory to tmp-dir-name Path("~", tmp_dir_name).chdir; std.file.getcwd.should.equal(home_tmp._path); }
Change current working directory to this.