CINXE.COM
build/clobber_unittest.py - chromium/src - Git at Google
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>build/clobber_unittest.py - chromium/src - Git at Google</title><link rel="stylesheet" type="text/css" href="/+static/base.css"><link rel="stylesheet" type="text/css" href="/+static/prettify/prettify.css"><!-- default customHeadTagPart --></head><body class="Site"><header class="Site-header"><div class="Header"><a class="Header-image" href="/"><img src="//www.gstatic.com/images/branding/lockups/2x/lockup_git_color_108x24dp.png" width="108" height="24" alt="Google Git"></a><div class="Header-menu"> <a class="Header-menuItem" href="https://accounts.google.com/AccountChooser?faa=1&service=gerritcodereview&continue=https://chromium.googlesource.com/login/chromium/src/%2B/refs/tags/130.0.6723.141/build/clobber_unittest.py">Sign in</a> </div></div></header><div class="Site-content"><div class="Container "><div class="Breadcrumbs"><a class="Breadcrumbs-crumb" href="/?format=HTML">chromium</a> / <a class="Breadcrumbs-crumb" href="/chromium/">chromium</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/">src</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/130.0.6723.141">refs/tags/130.0.6723.141</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/130.0.6723.141/">.</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/130.0.6723.141/build">build</a> / <span class="Breadcrumbs-crumb">clobber_unittest.py</span></div><div class="u-sha1 u-monospace BlobSha1">blob: d38c447b14434a7c808cfe2e8a5989a2ba3aaa22 [<a href="/chromium/src/+/refs/tags/130.0.6723.141/build/clobber_unittest.py">file</a>] [<a href="/chromium/src/+log/refs/tags/130.0.6723.141/build/clobber_unittest.py">log</a>] [<a href="/chromium/src/+blame/refs/tags/130.0.6723.141/build/clobber_unittest.py">blame</a>]</div><table class="FileContents"><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="1"></td><td class="FileContents-lineContents" id="1"><span class="com">#!/usr/bin/env python3</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="2"></td><td class="FileContents-lineContents" id="2"><span class="com"># Copyright 2023 The Chromium Authors</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="3"></td><td class="FileContents-lineContents" id="3"><span class="com"># Use of this source code is governed by a BSD-style license that can be</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="4"></td><td class="FileContents-lineContents" id="4"><span class="com"># found in the LICENSE file.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="5"></td><td class="FileContents-lineContents" id="5"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="6"></td><td class="FileContents-lineContents" id="6"><span class="kwd">import</span><span class="pln"> os</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="7"></td><td class="FileContents-lineContents" id="7"><span class="kwd">import</span><span class="pln"> pathlib</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="8"></td><td class="FileContents-lineContents" id="8"><span class="kwd">import</span><span class="pln"> shutil</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="9"></td><td class="FileContents-lineContents" id="9"><span class="kwd">import</span><span class="pln"> sys</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="10"></td><td class="FileContents-lineContents" id="10"><span class="kwd">import</span><span class="pln"> tempfile</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="11"></td><td class="FileContents-lineContents" id="11"><span class="kwd">import</span><span class="pln"> textwrap</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="12"></td><td class="FileContents-lineContents" id="12"><span class="kwd">import</span><span class="pln"> unittest</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="13"></td><td class="FileContents-lineContents" id="13"><span class="kwd">from</span><span class="pln"> unittest </span><span class="kwd">import</span><span class="pln"> mock</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="14"></td><td class="FileContents-lineContents" id="14"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="15"></td><td class="FileContents-lineContents" id="15"><span class="kwd">import</span><span class="pln"> clobber</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="16"></td><td class="FileContents-lineContents" id="16"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="17"></td><td class="FileContents-lineContents" id="17"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="18"></td><td class="FileContents-lineContents" id="18"><span class="kwd">class</span><span class="pln"> </span><span class="typ">TestExtractBuildCommand</span><span class="pun">(</span><span class="pln">unittest</span><span class="pun">.</span><span class="typ">TestCase</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="19"></td><td class="FileContents-lineContents" id="19"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> setUp</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="20"></td><td class="FileContents-lineContents" id="20"><span class="pln"> self</span><span class="pun">.</span><span class="pln">build_ninja_file</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">build_ninja_path </span><span class="pun">=</span><span class="pln"> tempfile</span><span class="pun">.</span><span class="pln">mkstemp</span><span class="pun">(</span><span class="pln">text</span><span class="pun">=</span><span class="kwd">True</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="21"></td><td class="FileContents-lineContents" id="21"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="22"></td><td class="FileContents-lineContents" id="22"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> tearDown</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="23"></td><td class="FileContents-lineContents" id="23"><span class="pln"> os</span><span class="pun">.</span><span class="pln">close</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_ninja_file</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="24"></td><td class="FileContents-lineContents" id="24"><span class="pln"> os</span><span class="pun">.</span><span class="pln">remove</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_ninja_path</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="25"></td><td class="FileContents-lineContents" id="25"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="26"></td><td class="FileContents-lineContents" id="26"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> test_normal_extraction</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="27"></td><td class="FileContents-lineContents" id="27"><span class="pln"> build_ninja_file_contents </span><span class="pun">=</span><span class="pln"> textwrap</span><span class="pun">.</span><span class="pln">dedent</span><span class="pun">(</span><span class="str">"""</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="28"></td><td class="FileContents-lineContents" id="28"><span class="str"> ninja_required_version = 1.7.2</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="29"></td><td class="FileContents-lineContents" id="29"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="30"></td><td class="FileContents-lineContents" id="30"><span class="str"> rule gn</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="31"></td><td class="FileContents-lineContents" id="31"><span class="str"> command = ../../buildtools/gn --root=../.. -q --regeneration gen .</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="32"></td><td class="FileContents-lineContents" id="32"><span class="str"> pool = console</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="33"></td><td class="FileContents-lineContents" id="33"><span class="str"> description = Regenerating ninja files</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="34"></td><td class="FileContents-lineContents" id="34"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="35"></td><td class="FileContents-lineContents" id="35"><span class="str"> build build.ninja.stamp: gn</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="36"></td><td class="FileContents-lineContents" id="36"><span class="str"> generator = 1</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="37"></td><td class="FileContents-lineContents" id="37"><span class="str"> depfile = build.ninja.d</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="38"></td><td class="FileContents-lineContents" id="38"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="39"></td><td class="FileContents-lineContents" id="39"><span class="str"> build build.ninja: phony build.ninja.stamp</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="40"></td><td class="FileContents-lineContents" id="40"><span class="str"> generator = 1</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="41"></td><td class="FileContents-lineContents" id="41"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="42"></td><td class="FileContents-lineContents" id="42"><span class="str"> pool build_toolchain_action_pool</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="43"></td><td class="FileContents-lineContents" id="43"><span class="str"> depth = 72</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="44"></td><td class="FileContents-lineContents" id="44"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="45"></td><td class="FileContents-lineContents" id="45"><span class="str"> pool build_toolchain_link_pool</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="46"></td><td class="FileContents-lineContents" id="46"><span class="str"> depth = 23</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="47"></td><td class="FileContents-lineContents" id="47"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="48"></td><td class="FileContents-lineContents" id="48"><span class="str"> subninja toolchain.ninja</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="49"></td><td class="FileContents-lineContents" id="49"><span class="str"> subninja clang_newlib_x64/toolchain.ninja</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="50"></td><td class="FileContents-lineContents" id="50"><span class="str"> subninja glibc_x64/toolchain.ninja</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="51"></td><td class="FileContents-lineContents" id="51"><span class="str"> subninja irt_x64/toolchain.ninja</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="52"></td><td class="FileContents-lineContents" id="52"><span class="str"> subninja nacl_bootstrap_x64/toolchain.ninja</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="53"></td><td class="FileContents-lineContents" id="53"><span class="str"> subninja newlib_pnacl/toolchain.ninja</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="54"></td><td class="FileContents-lineContents" id="54"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="55"></td><td class="FileContents-lineContents" id="55"><span class="str"> build blink_python_tests: phony obj/blink_python_tests.stamp</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="56"></td><td class="FileContents-lineContents" id="56"><span class="str"> build blink_tests: phony obj/blink_tests.stamp</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="57"></td><td class="FileContents-lineContents" id="57"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="58"></td><td class="FileContents-lineContents" id="58"><span class="str"> default all</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="59"></td><td class="FileContents-lineContents" id="59"><span class="str"> """</span><span class="pun">)</span><span class="pln"> </span><span class="com"># Based off of a standard linux build dir.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="60"></td><td class="FileContents-lineContents" id="60"><span class="pln"> </span><span class="kwd">with</span><span class="pln"> open</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_ninja_path</span><span class="pun">,</span><span class="pln"> </span><span class="str">'w'</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">as</span><span class="pln"> f</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="61"></td><td class="FileContents-lineContents" id="61"><span class="pln"> f</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">build_ninja_file_contents</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="62"></td><td class="FileContents-lineContents" id="62"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="63"></td><td class="FileContents-lineContents" id="63"><span class="pln"> expected_build_ninja_file_contents </span><span class="pun">=</span><span class="pln"> textwrap</span><span class="pun">.</span><span class="pln">dedent</span><span class="pun">(</span><span class="str">"""</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="64"></td><td class="FileContents-lineContents" id="64"><span class="str"> ninja_required_version = 1.7.2</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="65"></td><td class="FileContents-lineContents" id="65"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="66"></td><td class="FileContents-lineContents" id="66"><span class="str"> rule gn</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="67"></td><td class="FileContents-lineContents" id="67"><span class="str"> command = ../../buildtools/gn --root=../.. -q --regeneration gen .</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="68"></td><td class="FileContents-lineContents" id="68"><span class="str"> pool = console</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="69"></td><td class="FileContents-lineContents" id="69"><span class="str"> description = Regenerating ninja files</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="70"></td><td class="FileContents-lineContents" id="70"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="71"></td><td class="FileContents-lineContents" id="71"><span class="str"> build build.ninja.stamp: gn</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="72"></td><td class="FileContents-lineContents" id="72"><span class="str"> generator = 1</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="73"></td><td class="FileContents-lineContents" id="73"><span class="str"> depfile = build.ninja.d</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="74"></td><td class="FileContents-lineContents" id="74"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="75"></td><td class="FileContents-lineContents" id="75"><span class="str"> build build.ninja: phony build.ninja.stamp</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="76"></td><td class="FileContents-lineContents" id="76"><span class="str"> generator = 1</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="77"></td><td class="FileContents-lineContents" id="77"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="78"></td><td class="FileContents-lineContents" id="78"><span class="str"> """</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="79"></td><td class="FileContents-lineContents" id="79"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="80"></td><td class="FileContents-lineContents" id="80"><span class="pln"> self</span><span class="pun">.</span><span class="pln">assertEqual</span><span class="pun">(</span><span class="pln">clobber</span><span class="pun">.</span><span class="pln">extract_gn_build_commands</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_ninja_path</span><span class="pun">),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="81"></td><td class="FileContents-lineContents" id="81"><span class="pln"> expected_build_ninja_file_contents</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="82"></td><td class="FileContents-lineContents" id="82"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="83"></td><td class="FileContents-lineContents" id="83"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> test_unexpected_format</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="84"></td><td class="FileContents-lineContents" id="84"><span class="pln"> </span><span class="com"># No "build build.ninja:" line should make it return an empty string.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="85"></td><td class="FileContents-lineContents" id="85"><span class="pln"> build_ninja_file_contents </span><span class="pun">=</span><span class="pln"> textwrap</span><span class="pun">.</span><span class="pln">dedent</span><span class="pun">(</span><span class="str">"""</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="86"></td><td class="FileContents-lineContents" id="86"><span class="str"> ninja_required_version = 1.7.2</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="87"></td><td class="FileContents-lineContents" id="87"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="88"></td><td class="FileContents-lineContents" id="88"><span class="str"> rule gn</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="89"></td><td class="FileContents-lineContents" id="89"><span class="str"> command = ../../buildtools/gn --root=../.. -q --regeneration gen .</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="90"></td><td class="FileContents-lineContents" id="90"><span class="str"> pool = console</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="91"></td><td class="FileContents-lineContents" id="91"><span class="str"> description = Regenerating ninja files</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="92"></td><td class="FileContents-lineContents" id="92"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="93"></td><td class="FileContents-lineContents" id="93"><span class="str"> subninja toolchain.ninja</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="94"></td><td class="FileContents-lineContents" id="94"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="95"></td><td class="FileContents-lineContents" id="95"><span class="str"> build blink_python_tests: phony obj/blink_python_tests.stamp</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="96"></td><td class="FileContents-lineContents" id="96"><span class="str"> build blink_tests: phony obj/blink_tests.stamp</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="97"></td><td class="FileContents-lineContents" id="97"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="98"></td><td class="FileContents-lineContents" id="98"><span class="str"> """</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="99"></td><td class="FileContents-lineContents" id="99"><span class="pln"> </span><span class="kwd">with</span><span class="pln"> open</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_ninja_path</span><span class="pun">,</span><span class="pln"> </span><span class="str">'w'</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">as</span><span class="pln"> f</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="100"></td><td class="FileContents-lineContents" id="100"><span class="pln"> f</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">build_ninja_file_contents</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="101"></td><td class="FileContents-lineContents" id="101"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="102"></td><td class="FileContents-lineContents" id="102"><span class="pln"> self</span><span class="pun">.</span><span class="pln">assertEqual</span><span class="pun">(</span><span class="pln">clobber</span><span class="pun">.</span><span class="pln">extract_gn_build_commands</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_ninja_path</span><span class="pun">),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="103"></td><td class="FileContents-lineContents" id="103"><span class="pln"> </span><span class="str">''</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="104"></td><td class="FileContents-lineContents" id="104"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="105"></td><td class="FileContents-lineContents" id="105"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="106"></td><td class="FileContents-lineContents" id="106"><span class="kwd">class</span><span class="pln"> </span><span class="typ">TestDelete</span><span class="pun">(</span><span class="pln">unittest</span><span class="pun">.</span><span class="typ">TestCase</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="107"></td><td class="FileContents-lineContents" id="107"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> setUp</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="108"></td><td class="FileContents-lineContents" id="108"><span class="pln"> self</span><span class="pun">.</span><span class="pln">build_dir </span><span class="pun">=</span><span class="pln"> tempfile</span><span class="pun">.</span><span class="pln">mkdtemp</span><span class="pun">()</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="109"></td><td class="FileContents-lineContents" id="109"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="110"></td><td class="FileContents-lineContents" id="110"><span class="pln"> pathlib</span><span class="pun">.</span><span class="typ">Path</span><span class="pun">(</span><span class="pln">os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_dir</span><span class="pun">,</span><span class="pln"> </span><span class="str">'build.ninja'</span><span class="pun">)).</span><span class="pln">touch</span><span class="pun">()</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="111"></td><td class="FileContents-lineContents" id="111"><span class="pln"> pathlib</span><span class="pun">.</span><span class="typ">Path</span><span class="pun">(</span><span class="pln">os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_dir</span><span class="pun">,</span><span class="pln"> </span><span class="str">'build.ninja.d'</span><span class="pun">)).</span><span class="pln">touch</span><span class="pun">()</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="112"></td><td class="FileContents-lineContents" id="112"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="113"></td><td class="FileContents-lineContents" id="113"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> tearDown</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="114"></td><td class="FileContents-lineContents" id="114"><span class="pln"> shutil</span><span class="pun">.</span><span class="pln">rmtree</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_dir</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="115"></td><td class="FileContents-lineContents" id="115"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="116"></td><td class="FileContents-lineContents" id="116"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> test_delete_build_dir_full</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="117"></td><td class="FileContents-lineContents" id="117"><span class="pln"> </span><span class="com"># Create a dummy file in the build dir and ensure it gets removed.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="118"></td><td class="FileContents-lineContents" id="118"><span class="pln"> dummy_file </span><span class="pun">=</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_dir</span><span class="pun">,</span><span class="pln"> </span><span class="str">'dummy'</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="119"></td><td class="FileContents-lineContents" id="119"><span class="pln"> pathlib</span><span class="pun">.</span><span class="typ">Path</span><span class="pun">(</span><span class="pln">dummy_file</span><span class="pun">).</span><span class="pln">touch</span><span class="pun">()</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="120"></td><td class="FileContents-lineContents" id="120"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="121"></td><td class="FileContents-lineContents" id="121"><span class="pln"> clobber</span><span class="pun">.</span><span class="pln">delete_build_dir</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_dir</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="122"></td><td class="FileContents-lineContents" id="122"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="123"></td><td class="FileContents-lineContents" id="123"><span class="pln"> self</span><span class="pun">.</span><span class="pln">assertFalse</span><span class="pun">(</span><span class="pln">os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">exists</span><span class="pun">(</span><span class="pln">dummy_file</span><span class="pun">))</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="124"></td><td class="FileContents-lineContents" id="124"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="125"></td><td class="FileContents-lineContents" id="125"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> test_delete_build_dir_fail</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="126"></td><td class="FileContents-lineContents" id="126"><span class="pln"> </span><span class="com"># Make delete_dir() throw to ensure it's handled gracefully.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="127"></td><td class="FileContents-lineContents" id="127"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="128"></td><td class="FileContents-lineContents" id="128"><span class="pln"> </span><span class="kwd">with</span><span class="pln"> mock</span><span class="pun">.</span><span class="pln">patch</span><span class="pun">(</span><span class="str">'clobber._clean_dir'</span><span class="pun">,</span><span class="pln"> side_effect</span><span class="pun">=</span><span class="typ">OSError</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="129"></td><td class="FileContents-lineContents" id="129"><span class="pln"> </span><span class="kwd">with</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">assertRaises</span><span class="pun">(</span><span class="typ">OSError</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="130"></td><td class="FileContents-lineContents" id="130"><span class="pln"> clobber</span><span class="pun">.</span><span class="pln">delete_build_dir</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_dir</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="131"></td><td class="FileContents-lineContents" id="131"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="132"></td><td class="FileContents-lineContents" id="132"><span class="pln"> </span><span class="lit">@unittest</span><span class="pun">.</span><span class="pln">skipIf</span><span class="pun">(</span><span class="pln">sys</span><span class="pun">.</span><span class="pln">platform </span><span class="pun">==</span><span class="pln"> </span><span class="str">'win32'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Symlinks are not allowed on Windows by default'</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="133"></td><td class="FileContents-lineContents" id="133"><span class="pln"> </span><span class="kwd">def</span><span class="pln"> test_delete_build_dir_link</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="134"></td><td class="FileContents-lineContents" id="134"><span class="pln"> </span><span class="kwd">with</span><span class="pln"> tempfile</span><span class="pun">.</span><span class="typ">TemporaryDirectory</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">as</span><span class="pln"> tmpdir</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="135"></td><td class="FileContents-lineContents" id="135"><span class="pln"> </span><span class="com"># create a symlink.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="136"></td><td class="FileContents-lineContents" id="136"><span class="pln"> build_dir </span><span class="pun">=</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">tmpdir</span><span class="pun">,</span><span class="pln"> </span><span class="str">'link'</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="137"></td><td class="FileContents-lineContents" id="137"><span class="pln"> os</span><span class="pun">.</span><span class="pln">symlink</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">build_dir</span><span class="pun">,</span><span class="pln"> build_dir</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="138"></td><td class="FileContents-lineContents" id="138"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="139"></td><td class="FileContents-lineContents" id="139"><span class="pln"> </span><span class="com"># create a dummy file.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="140"></td><td class="FileContents-lineContents" id="140"><span class="pln"> dummy_file </span><span class="pun">=</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">build_dir</span><span class="pun">,</span><span class="pln"> </span><span class="str">'dummy'</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="141"></td><td class="FileContents-lineContents" id="141"><span class="pln"> pathlib</span><span class="pun">.</span><span class="typ">Path</span><span class="pun">(</span><span class="pln">dummy_file</span><span class="pun">).</span><span class="pln">touch</span><span class="pun">()</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="142"></td><td class="FileContents-lineContents" id="142"><span class="pln"> clobber</span><span class="pun">.</span><span class="pln">delete_build_dir</span><span class="pun">(</span><span class="pln">build_dir</span><span class="pun">)</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="143"></td><td class="FileContents-lineContents" id="143"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="144"></td><td class="FileContents-lineContents" id="144"><span class="pln"> self</span><span class="pun">.</span><span class="pln">assertFalse</span><span class="pun">(</span><span class="pln">os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">exists</span><span class="pun">(</span><span class="pln">dummy_file</span><span class="pun">))</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="145"></td><td class="FileContents-lineContents" id="145"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="146"></td><td class="FileContents-lineContents" id="146"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="147"></td><td class="FileContents-lineContents" id="147"><span class="kwd">if</span><span class="pln"> __name__ </span><span class="pun">==</span><span class="pln"> </span><span class="str">'__main__'</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="148"></td><td class="FileContents-lineContents" id="148"><span class="pln"> unittest</span><span class="pun">.</span><span class="pln">main</span><span class="pun">()</span></td></tr></table><script nonce="BoLsmsNG5zRm0y7L9yq_eA">for (let lineNumEl of document.querySelectorAll('td.u-lineNum')) {lineNumEl.onclick = () => {window.location.hash = `#${lineNumEl.getAttribute('data-line-number')}`;};}</script></div> <!-- Container --></div> <!-- Site-content --><footer class="Site-footer"><div class="Footer"><span class="Footer-poweredBy">Powered by <a href="https://gerrit.googlesource.com/gitiles/">Gitiles</a>| <a href="https://policies.google.com/privacy">Privacy</a>| <a href="https://policies.google.com/terms">Terms</a></span><span class="Footer-formats"><a class="u-monospace Footer-formatsItem" href="?format=TEXT">txt</a> <a class="u-monospace Footer-formatsItem" href="?format=JSON">json</a></span></div></footer></body></html>