#!/usr/bin/env python3 # Copyright 2023 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
import os import pathlib import shutil import sys import tempfile import textwrap import unittest from unittest import mock
import clobber
class TestExtractBuildCommand(unittest.TestCase): def setUp(self):
self.build_ninja_file, self.build_ninja_path = tempfile.mkstemp(text=True)
def test_unexpected_format(self): # No "build build.ninja:" line should make it return an empty string.
build_ninja_file_contents = textwrap.dedent("""
ninja_required_version = 1.7.2
rule gn
command = ../../buildtools/gn --root=../.. -q --regeneration gen .
pool = console
description = Regenerating ninja files
def test_delete_build_dir_full(self): # Create a dummy file in the build dir and ensure it gets removed.
dummy_file = os.path.join(self.build_dir, 'dummy')
pathlib.Path(dummy_file).touch()
clobber.delete_build_dir(self.build_dir)
self.assertFalse(os.path.exists(dummy_file))
def test_delete_build_dir_fail(self): # Make delete_dir() throw to ensure it's handled gracefully.
with mock.patch('clobber._clean_dir', side_effect=OSError): with self.assertRaises(OSError):
clobber.delete_build_dir(self.build_dir)
@unittest.skipIf(sys.platform == 'win32', 'Symlinks are not allowed on Windows by default') def test_delete_build_dir_link(self): with tempfile.TemporaryDirectory() as tmpdir: # create a symlink.
build_dir = os.path.join(tmpdir, 'link')
os.symlink(self.build_dir, build_dir)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.