Skip to content

Don't use self.date unconditionally for program_out_of_date() #80426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def download_stage0(self):

if self.rustc().startswith(self.bin_root()) and \
(not os.path.exists(self.rustc()) or
self.program_out_of_date(self.rustc_stamp())):
self.program_out_of_date(self.rustc_stamp(), self.date)):
if os.path.exists(self.bin_root()):
shutil.rmtree(self.bin_root())
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
Expand Down Expand Up @@ -427,7 +427,7 @@ def download_stage0(self):
self.fix_bin_or_dylib("{}/bin/rustfmt".format(self.bin_root()))
self.fix_bin_or_dylib("{}/bin/cargo-fmt".format(self.bin_root()))
with output(self.rustfmt_stamp()) as rustfmt_stamp:
rustfmt_stamp.write(self.date + self.rustfmt_channel)
rustfmt_stamp.write(self.rustfmt_channel)

if self.downloading_llvm():
# We want the most recent LLVM submodule update to avoid downloading
Expand All @@ -454,7 +454,7 @@ def download_stage0(self):
for binary in ["llvm-config", "FileCheck"]:
self.fix_bin_or_dylib("{}/bin/{}".format(self.llvm_root(), binary))
with output(self.llvm_stamp()) as llvm_stamp:
llvm_stamp.write(self.date + llvm_sha + str(llvm_assertions))
llvm_stamp.write(llvm_sha + str(llvm_assertions))

def downloading_llvm(self):
opt = self.get_toml('download-ci-llvm', 'llvm')
Expand Down Expand Up @@ -616,12 +616,12 @@ def llvm_stamp(self):
return os.path.join(self.llvm_root(), '.llvm-stamp')


def program_out_of_date(self, stamp_path, extra=""):
def program_out_of_date(self, stamp_path, key):
"""Check if the given program stamp is out of date"""
if not os.path.exists(stamp_path) or self.clean:
return True
with open(stamp_path, 'r') as stamp:
return (self.date + extra) != stamp.read()
return key != stamp.read()

def bin_root(self):
"""Return the binary root directory
Expand Down
11 changes: 6 additions & 5 deletions src/bootstrap/bootstrap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def setUp(self):
self.build.build_dir = self.container
self.rustc_stamp_path = os.path.join(self.container, "stage0",
".rustc-stamp")
self.key = self.build.date + str(None)

def tearDown(self):
rmtree(self.container)
Expand All @@ -78,19 +79,19 @@ def test_stamp_path_does_not_exists(self):
"""Return True when the stamp file does not exists"""
if os.path.exists(self.rustc_stamp_path):
os.unlink(self.rustc_stamp_path)
self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path))
self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path, self.key))

def test_dates_are_different(self):
"""Return True when the dates are different"""
with open(self.rustc_stamp_path, "w") as rustc_stamp:
rustc_stamp.write("2017-06-14")
self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path))
rustc_stamp.write("2017-06-14None")
self.assertTrue(self.build.program_out_of_date(self.rustc_stamp_path, self.key))

def test_same_dates(self):
"""Return False both dates match"""
with open(self.rustc_stamp_path, "w") as rustc_stamp:
rustc_stamp.write("2017-06-15")
self.assertFalse(self.build.program_out_of_date(self.rustc_stamp_path))
rustc_stamp.write("2017-06-15None")
self.assertFalse(self.build.program_out_of_date(self.rustc_stamp_path, self.key))


if __name__ == '__main__':
Expand Down