|
| 1 | +import subprocess |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | + |
| 6 | +def test_stash_push(xtl_clone, commit_env_config, git2cpp_path, tmp_path): |
| 7 | + assert (tmp_path / "xtl").exists() |
| 8 | + xtl_path = tmp_path / "xtl" |
| 9 | + |
| 10 | + p = xtl_path / "mook_file.txt" |
| 11 | + p.write_text("") |
| 12 | + |
| 13 | + cmd_add = [git2cpp_path, "add", "mook_file.txt"] |
| 14 | + p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True) |
| 15 | + assert p_add.returncode == 0 |
| 16 | + |
| 17 | + cmd_status = [git2cpp_path, "status"] |
| 18 | + p_status = subprocess.run(cmd_status, capture_output=True, cwd=xtl_path, text=True) |
| 19 | + assert p_status.returncode == 0 |
| 20 | + assert "mook_file" in p_status.stdout |
| 21 | + |
| 22 | + cmd_stash = [git2cpp_path, "stash"] |
| 23 | + p_stash = subprocess.run(cmd_stash, capture_output=True, cwd=xtl_path, text=True) |
| 24 | + assert p_stash.returncode == 0 |
| 25 | + |
| 26 | + p_status_2 = subprocess.run( |
| 27 | + cmd_status, capture_output=True, cwd=xtl_path, text=True |
| 28 | + ) |
| 29 | + assert p_status_2.returncode == 0 |
| 30 | + assert "mook_file" not in p_status_2.stdout |
| 31 | + |
| 32 | + |
| 33 | +def test_stash_list(xtl_clone, commit_env_config, git2cpp_path, tmp_path): |
| 34 | + assert (tmp_path / "xtl").exists() |
| 35 | + xtl_path = tmp_path / "xtl" |
| 36 | + |
| 37 | + p = xtl_path / "mook_file.txt" |
| 38 | + p.write_text("") |
| 39 | + |
| 40 | + cmd_add = [git2cpp_path, "add", "mook_file.txt"] |
| 41 | + p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True) |
| 42 | + assert p_add.returncode == 0 |
| 43 | + |
| 44 | + cmd_list = [git2cpp_path, "stash", "list"] |
| 45 | + p_list = subprocess.run(cmd_list, capture_output=True, cwd=xtl_path, text=True) |
| 46 | + assert p_list.returncode == 0 |
| 47 | + assert "stash@" not in p_list.stdout |
| 48 | + |
| 49 | + cmd_stash = [git2cpp_path, "stash"] |
| 50 | + p_stash = subprocess.run(cmd_stash, capture_output=True, cwd=xtl_path, text=True) |
| 51 | + assert p_stash.returncode == 0 |
| 52 | + |
| 53 | + # p_list_2 = subprocess.run(cmd_list, capture_output=True, cwd=xtl_path, text=True) |
| 54 | + # assert p_list_2.returncode == 0 |
| 55 | + # print("second: \n", p_list_2.stdout, "\n\n") |
| 56 | + # # assert "stash@{0}" in p_list_2.stdout |
| 57 | + |
| 58 | + |
| 59 | +def test_stash_pop(xtl_clone, commit_env_config, git2cpp_path, tmp_path): |
| 60 | + assert (tmp_path / "xtl").exists() |
| 61 | + xtl_path = tmp_path / "xtl" |
| 62 | + |
| 63 | + p = xtl_path / "mook_file.txt" |
| 64 | + p.write_text("") |
| 65 | + |
| 66 | + cmd_add = [git2cpp_path, "add", "mook_file.txt"] |
| 67 | + p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True) |
| 68 | + assert p_add.returncode == 0 |
| 69 | + |
| 70 | + cmd_stash = [git2cpp_path, "stash"] |
| 71 | + p_stash = subprocess.run(cmd_stash, capture_output=True, cwd=xtl_path, text=True) |
| 72 | + assert p_stash.returncode == 0 |
| 73 | + |
| 74 | + cmd_status = [git2cpp_path, "status"] |
| 75 | + p_status = subprocess.run(cmd_status, capture_output=True, cwd=xtl_path, text=True) |
| 76 | + assert p_status.returncode == 0 |
| 77 | + assert "mook_file" not in p_status.stdout |
| 78 | + |
| 79 | + # cmd_pop = [git2cpp_path, "stash", "pop"] |
| 80 | + # p_pop = subprocess.run(cmd_pop, capture_output=True, cwd=xtl_path, text=True) |
| 81 | + # assert p_pop.returncode == 0 |
| 82 | + |
| 83 | + # p_status_2 = subprocess.run( |
| 84 | + # cmd_status, capture_output=True, cwd=xtl_path, text=True |
| 85 | + # ) |
| 86 | + # assert p_status_2.returncode == 0 |
| 87 | + # print(p_status_2.stdout) |
| 88 | + # assert "mook_file" in p_status.stdout |
| 89 | + # |
| 90 | + # cmd_list = [git2cpp_path, "stash", "list"] |
| 91 | + # p_list = subprocess.run(cmd_list, capture_output=True, cwd=xtl_path, text=True) |
| 92 | + # assert p_list.returncode == 0 |
| 93 | + # assert p_list.stdout == "" |
| 94 | + |
| 95 | + |
| 96 | +def test_stash_apply(xtl_clone, commit_env_config, git2cpp_path, tmp_path): |
| 97 | + assert (tmp_path / "xtl").exists() |
| 98 | + xtl_path = tmp_path / "xtl" |
| 99 | + |
| 100 | + p = xtl_path / "mook_file.txt" |
| 101 | + p.write_text("") |
| 102 | + |
| 103 | + cmd_add = [git2cpp_path, "add", "mook_file.txt"] |
| 104 | + p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True) |
| 105 | + assert p_add.returncode == 0 |
| 106 | + |
| 107 | + cmd_stash = [git2cpp_path, "stash"] |
| 108 | + p_stash = subprocess.run(cmd_stash, capture_output=True, cwd=xtl_path, text=True) |
| 109 | + assert p_stash.returncode == 0 |
| 110 | + |
| 111 | + cmd_status = [git2cpp_path, "status"] |
| 112 | + p_status = subprocess.run(cmd_status, capture_output=True, cwd=xtl_path, text=True) |
| 113 | + assert p_status.returncode == 0 |
| 114 | + assert "mook_file" not in p_status.stdout |
| 115 | + |
| 116 | + # cmd_pop = [git2cpp_path, "stash", "pop"] |
| 117 | + # p_pop = subprocess.run(cmd_pop, capture_output=True, cwd=xtl_path, text=True) |
| 118 | + # assert p_pop.returncode == 0 |
| 119 | + |
| 120 | + # p_status_2 = subprocess.run( |
| 121 | + # cmd_status, capture_output=True, cwd=xtl_path, text=True |
| 122 | + # ) |
| 123 | + # assert p_status_2.returncode == 0 |
| 124 | + # print(p_status_2.stdout) |
| 125 | + # assert "mook_file" in p_status.stdout |
| 126 | + # |
| 127 | + # cmd_list = [git2cpp_path, "stash", "list"] |
| 128 | + # p_list = subprocess.run(cmd_list, capture_output=True, cwd=xtl_path, text=True) |
| 129 | + # assert p_list.returncode == 0 |
| 130 | + # assert "stash@{0}" in p_list.stdout |
0 commit comments