Skip to content
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
6 changes: 4 additions & 2 deletions components/mach_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ def check_for_update(self, library):
if not result:
return (None, None)

parts = result.split(" ")
return (parts[0], string_date_to_uniform_string_date(parts[1]))
# ./mach vendor prints "<revision> <timestamp>", and the timestamp is not
# space-free on every host (googlesource: "Wed Sep 09 17:56:48 2026").
revision, timestamp = result.split(" ", 1)
return (revision, string_date_to_uniform_string_date(timestamp))

@logEntryExit
def vendor(self, library, revision):
Expand Down
3 changes: 2 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"library",
"lambda_capture",
"class_passing",
"frequency"
"frequency",
"mach_vendor"
]

modules = []
Expand Down
53 changes: 53 additions & 0 deletions tests/mach_vendor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import sys
import unittest

sys.path.append(".")
sys.path.append("..")

from components.logging import SimpleLoggerConfig
from components.mach_vendor import VendorProvider
from components.utilities import Struct
from tests.mock_commandprovider import TestCommandProvider

LIBRARY = Struct(**{'yaml_path': 'media/libyuv/moz.yaml'})
REVISION = "3f3735e3f39c68d33104add994bfe5d055b32e17"


class TestVendorProvider(unittest.TestCase):
def _check_for_update(self, mach_output):
"""Run check_for_update against a mocked `./mach vendor` stdout."""
commandProvider = TestCommandProvider({
'test_mappings': {
"./mach vendor --check-for-update": lambda: mach_output
}
})
commandProvider.update_config(SimpleLoggerConfig)

vendorProvider = VendorProvider({})
vendorProvider.update_config(dict(SimpleLoggerConfig, CommandProvider=commandProvider))
return vendorProvider.check_for_update(LIBRARY)

def testGooglesourceTimestamp(self):
# googlesource reports commit dates in git's default format, so the
# timestamp field contains spaces and must not be split on them.
self.assertEqual(
self._check_for_update(REVISION + " Wed Sep 09 17:56:48 2026"),
(REVISION, "2026-09-09 17:56:48"))

def testISO8601Timestamp(self):
self.assertEqual(
self._check_for_update(REVISION + " 2026-09-09T17:56:48Z"),
(REVISION, "2026-09-09 17:56:48"))

def testNoUpdateAvailable(self):
self.assertEqual(self._check_for_update(""), (None, None))


if __name__ == "__main__":
unittest.main(verbosity=0)
Loading