@@ -1641,6 +1641,7 @@ def setUp(self):
16411641 self .github_env = self .root / "github_env"
16421642 self .github_output = self .root / "github_output"
16431643 self .git_log = self .root / "git.log"
1644+ self .git_clean_log = self .root / "git-clean.log"
16441645 self .cp_log = self .root / "cp.log"
16451646 self .version_file = self .root / "CHROMIUM_VERSION"
16461647 self .version_file .write_text (
@@ -1701,6 +1702,14 @@ def _write_fake_git(self):
17011702fi
17021703cmd="${1:-}"
17031704shift || true
1705+ repo="${repo:-.}"
1706+ repo_was_cleaned() {
1707+ [ -f "$GIT_CLEAN_LOG" ] || return 1
1708+ while IFS= read -r cleaned_repo; do
1709+ [ "$cleaned_repo" = "$repo" ] && return 0
1710+ done < "$GIT_CLEAN_LOG"
1711+ return 1
1712+ }
17041713case "$cmd" in
17051714 rev-parse)
17061715 target="${1:-}"
@@ -1717,6 +1726,7 @@ def _write_fake_git(self):
17171726 esac
17181727 ;;
17191728 status)
1729+ repo_was_cleaned && exit 0
17201730 if [ -n "${GIT_DIRTY_REPO:-}" ]; then
17211731 if [ "$repo" = "$GIT_DIRTY_REPO" ]; then
17221732 printf '%b' "${GIT_DIRTY_STATUS:- M nested-change\\ n}"
@@ -1725,6 +1735,9 @@ def _write_fake_git(self):
17251735 printf '%b' "${GIT_STATUS:-}"
17261736 fi
17271737 ;;
1738+ clean)
1739+ printf '%s\\ n' "$repo" >> "$GIT_CLEAN_LOG"
1740+ ;;
17281741esac
17291742"""
17301743 )
@@ -1761,6 +1774,7 @@ def _env(self, **overrides):
17611774 "BROWSEROS_CHROMIUM_VERSION_FILE" : str (self .version_file ),
17621775 "CP_LOG" : str (self .cp_log ),
17631776 "GIT_HEAD" : self .head ,
1777+ "GIT_CLEAN_LOG" : str (self .git_clean_log ),
17641778 "GIT_LOG" : str (self .git_log ),
17651779 "GITHUB_ENV" : str (self .github_env ),
17661780 "GITHUB_OUTPUT" : str (self .github_output ),
@@ -1874,7 +1888,7 @@ def test_setup_reaps_only_marked_stale_owned_workspaces(self):
18741888 self .assertTrue (Path (self ._outputs ()["workspace_root" ]).exists ())
18751889 self .assertTrue (self .base_root .exists ())
18761890
1877- def test_setup_reaps_stale_workspaces_before_dirty_base_failure (self ):
1891+ def test_setup_reaps_stale_workspaces_before_repairing_dirty_base (self ):
18781892 parent = self ._workspace_parent ()
18791893 parent .mkdir ()
18801894 stale = self ._workspace_root ("old-1" )
@@ -1888,10 +1902,9 @@ def test_setup_reaps_stale_workspaces_before_dirty_base_failure(self):
18881902 GIT_STATUS = " M chrome/app/generated_resources.grd\n " ,
18891903 )
18901904
1891- self .assertNotEqual (result .returncode , 0 )
1892- self .assertIn ("tracked or untracked changes" , result .stderr + result .stdout )
1905+ self .assertEqual (result .returncode , 0 , result .stderr + result .stdout )
18931906 self .assertFalse (stale .exists ())
1894- self .assertFalse (self ._workspace_root ().exists ())
1907+ self .assertTrue (self ._workspace_root ().exists ())
18951908 self .assertTrue (self .base_root .exists ())
18961909
18971910 def test_cleanup_ignores_unsafe_state_target (self ):
@@ -1969,29 +1982,27 @@ def test_setup_fails_when_base_is_not_at_pinned_chromium_tag(self):
19691982 self .assertIn ("does not match pinned" , result .stderr + result .stdout )
19701983 self .assertFalse (self ._workspace_root ().exists ())
19711984
1972- def test_setup_fails_when_base_has_tracked_changes (self ):
1985+ def test_setup_repairs_base_with_tracked_changes (self ):
19731986 result = self ._run_helper (
19741987 "setup" ,
19751988 self .base_src ,
19761989 GIT_STATUS = " M chrome/app/generated_resources.grd\n " ,
19771990 )
19781991
1979- self .assertNotEqual (result .returncode , 0 )
1980- self .assertIn ("tracked or untracked changes" , result .stderr + result .stdout )
1981- self .assertFalse (self ._workspace_root ().exists ())
1992+ self .assertEqual (result .returncode , 0 , result .stderr + result .stdout )
1993+ self .assertTrue (self ._workspace_root ().exists ())
19821994
1983- def test_setup_fails_when_base_has_untracked_changes (self ):
1995+ def test_setup_repairs_base_with_untracked_changes (self ):
19841996 result = self ._run_helper (
19851997 "setup" ,
19861998 self .base_src ,
19871999 GIT_STATUS = "?? chrome/browser/browseros/generated_resources.grd\n " ,
19882000 )
19892001
1990- self .assertNotEqual (result .returncode , 0 )
1991- self .assertIn ("tracked or untracked changes" , result .stderr + result .stdout )
1992- self .assertFalse (self ._workspace_root ().exists ())
2002+ self .assertEqual (result .returncode , 0 , result .stderr + result .stdout )
2003+ self .assertTrue (self ._workspace_root ().exists ())
19932004
1994- def test_setup_fails_when_nested_gclient_repo_has_changes (self ):
2005+ def test_setup_repairs_nested_gclient_repo_with_changes (self ):
19952006 nested_repo = self .base_src / "third_party" / "v8"
19962007 nested_repo .mkdir (parents = True )
19972008 (nested_repo / ".git" ).mkdir ()
@@ -2003,20 +2014,18 @@ def test_setup_fails_when_nested_gclient_repo_has_changes(self):
20032014 GIT_DIRTY_STATUS = " M src/builtins/generated.cc\n " ,
20042015 )
20052016
2006- self .assertNotEqual (result .returncode , 0 )
2007- self .assertIn (str (nested_repo .resolve ()), result .stderr + result .stdout )
2008- self .assertIn ("tracked or untracked changes" , result .stderr + result .stdout )
2009- self .assertFalse (self ._workspace_root ().exists ())
2017+ self .assertEqual (result .returncode , 0 , result .stderr + result .stdout )
2018+ self .assertTrue (self ._workspace_root ().exists ())
20102019
2011- def test_setup_fails_when_base_has_browseros_output_dirs (self ):
2020+ def test_setup_removes_browseros_output_dirs_from_base (self ):
20122021 out_dir = self .base_src / "out" / "Default_browseros_arm64"
20132022 out_dir .mkdir (parents = True )
20142023
20152024 result = self ._run_helper ("setup" , self .base_src )
20162025
2017- self .assertNotEqual (result .returncode , 0 )
2018- self .assertIn ( "BrowserOS output state" , result . stderr + result . stdout )
2019- self .assertFalse (self ._workspace_root ().exists ())
2026+ self .assertEqual (result .returncode , 0 , result . stderr + result . stdout )
2027+ self .assertFalse ( out_dir . exists () )
2028+ self .assertTrue (self ._workspace_root ().exists ())
20202029
20212030
20222031@unittest .skipIf (os .name == "nt" , "macOS signing helper shell tests run on POSIX" )
0 commit comments