MCPcopy
hub / github.com/commaai/openpilot / _make_commit

Method _make_commit

selfdrive/test/test_updated.py:123–161  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

121 raise Exception("timed out waiting for update to complete")
122
123 def _make_commit(self):
124 all_dirs, all_files = [], []
125 for root, dirs, files in os.walk(self.git_remote_dir):
126 if ".git" in root:
127 continue
128 for d in dirs:
129 all_dirs.append(os.path.join(root, d))
130 for f in files:
131 all_files.append(os.path.join(root, f))
132
133 # make a new dir and some new files
134 new_dir = os.path.join(self.git_remote_dir, "this_is_a_new_dir")
135 os.mkdir(new_dir)
136 for _ in range(random.randrange(5, 30)):
137 for d in (new_dir, random.choice(all_dirs)):
138 with tempfile.NamedTemporaryFile(dir=d, delete=False) as f:
139 f.write(os.urandom(random.randrange(1, 1000000)))
140
141 # modify some files
142 for f in random.sample(all_files, random.randrange(5, 50)):
143 with open(f, "w+") as ff:
144 txt = ff.readlines()
145 ff.seek(0)
146 for line in txt:
147 ff.write(line[::-1])
148
149 # remove some files
150 for f in random.sample(all_files, random.randrange(5, 50)):
151 os.remove(f)
152
153 # remove some dirs
154 for d in random.sample(all_dirs, random.randrange(1, 10)):
155 shutil.rmtree(d)
156
157 # commit the changes
158 self._run([
159 "git add -A",
160 "git commit -m 'an update'",
161 ], cwd=self.git_remote_dir)
162
163 def _check_update_state(self, update_available):
164 # make sure LastUpdateTime is recent

Callers 2

test_updateMethod · 0.95
test_update_loopMethod · 0.95

Calls 6

_runMethod · 0.95
appendMethod · 0.80
joinMethod · 0.80
writeMethod · 0.80
sampleMethod · 0.80
seekMethod · 0.80

Tested by

no test coverage detected