mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1439116 [wpt PR 9564] - Fix #7142: Change manifest update process, a=testonly
Automatic update from web-platform-testsFix #7142: Change manifest update process Earlier, interrupting the manifest-update could end up causing errors due to the non-atomicity of the process. Used tempfile to ensure that the file is written correctly. wpt-commits: 38612167f54c475836c122013756e92b9a8859cc wpt-pr: 9564 wpt-commits: 38612167f54c475836c122013756e92b9a8859cc wpt-pr: 9564
This commit is contained in:
parent
be5f871e8e
commit
231ef2c2be
@ -3,6 +3,7 @@ import os
|
||||
import re
|
||||
from collections import defaultdict
|
||||
from six import iteritems, itervalues, viewkeys, string_types
|
||||
from tempfile import mkstemp
|
||||
|
||||
from .item import ManualTest, WebdriverSpecTest, Stub, RefTestNode, RefTest, TestharnessTest, SupportFile, ConformanceCheckerTest, VisualTest
|
||||
from .log import get_logger
|
||||
@ -232,6 +233,11 @@ def write(manifest, manifest_path):
|
||||
dir_name = os.path.dirname(manifest_path)
|
||||
if not os.path.exists(dir_name):
|
||||
os.makedirs(dir_name)
|
||||
with open(manifest_path, "wb") as f:
|
||||
json.dump(manifest.to_json(), f, sort_keys=True, indent=1, separators=(',', ': '))
|
||||
f.write("\n")
|
||||
|
||||
fd, temp_manifest_path = mkstemp(dir=dir_name)
|
||||
temp_manifest = open(temp_manifest_path, "wb")
|
||||
json.dump(manifest.to_json(), temp_manifest,
|
||||
sort_keys=True, indent=1, separators=(',', ': '))
|
||||
temp_manifest.write("\n")
|
||||
os.rename(temp_manifest_path, manifest_path)
|
||||
os.close(fd)
|
||||
|
Loading…
Reference in New Issue
Block a user