Add public version macros.
Side note: tools/v8-info.sh seems to have been broken ever since the move to git. At least it's not more broken now. BUG=v8:3075 LOG=y TEST=./script_test.py Review URL: https://codereview.chromium.org/959713003 Cr-Commit-Position: refs/heads/master@{#26873}
This commit is contained in:
parent
bb13e7f746
commit
9dac60ad2d
@ -200,8 +200,8 @@ def _CommonChecks(input_api, output_api):
|
||||
|
||||
def _SkipTreeCheck(input_api, output_api):
|
||||
"""Check the env var whether we want to skip tree check.
|
||||
Only skip if src/version.cc has been updated."""
|
||||
src_version = 'src/version.cc'
|
||||
Only skip if include/v8-version.h has been updated."""
|
||||
src_version = 'include/v8-version.h'
|
||||
FilterFile = lambda file: file.LocalPath() == src_version
|
||||
if not input_api.AffectedSourceFiles(
|
||||
lambda file: file.LocalPath() == src_version):
|
||||
|
20
include/v8-version.h
Normal file
20
include/v8-version.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2015 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
|
||||
#define V8_INCLUDE_VERSION_H_
|
||||
|
||||
// These macros define the version number for the current version.
|
||||
// NOTE these macros are used by some of the tool scripts and the build
|
||||
// system so their names cannot be changed without changing the scripts.
|
||||
#define V8_MAJOR_VERSION 4
|
||||
#define V8_MINOR_VERSION 3
|
||||
#define V8_BUILD_NUMBER 0
|
||||
#define V8_PATCH_LEVEL 0
|
||||
|
||||
// Use 1 for candidates and 0 otherwise.
|
||||
// (Boolean macro values are not supported by all preprocessors.)
|
||||
#define V8_IS_CANDIDATE_VERSION 1
|
||||
|
||||
#endif // V8_INCLUDE_VERSION_H_
|
@ -19,6 +19,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "v8-version.h"
|
||||
#include "v8config.h"
|
||||
|
||||
// We reserve the V8_* prefix for macros defined in V8 public API and
|
||||
|
@ -2,27 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "include/v8-version.h"
|
||||
#include "src/v8.h"
|
||||
|
||||
#include "src/version.h"
|
||||
|
||||
// These macros define the version number for the current version.
|
||||
// NOTE these macros are used by some of the tool scripts and the build
|
||||
// system so their names cannot be changed without changing the scripts.
|
||||
#define MAJOR_VERSION 4
|
||||
#define MINOR_VERSION 3
|
||||
#define BUILD_NUMBER 0
|
||||
#define PATCH_LEVEL 0
|
||||
// Use 1 for candidates and 0 otherwise.
|
||||
// (Boolean macro values are not supported by all preprocessors.)
|
||||
#define IS_CANDIDATE_VERSION 1
|
||||
|
||||
// Define SONAME to have the build system put a specific SONAME into the
|
||||
// shared library instead the generic SONAME generated from the V8 version
|
||||
// number. This define is mainly used by the build system script.
|
||||
#define SONAME ""
|
||||
|
||||
#if IS_CANDIDATE_VERSION
|
||||
#if V8_IS_CANDIDATE_VERSION
|
||||
#define CANDIDATE_STRING " (candidate)"
|
||||
#else
|
||||
#define CANDIDATE_STRING ""
|
||||
@ -31,23 +20,24 @@
|
||||
#define SX(x) #x
|
||||
#define S(x) SX(x)
|
||||
|
||||
#if PATCH_LEVEL > 0
|
||||
#if V8_PATCH_LEVEL > 0
|
||||
#define VERSION_STRING \
|
||||
S(MAJOR_VERSION) "." S(MINOR_VERSION) "." S(BUILD_NUMBER) "." S(PATCH_LEVEL) \
|
||||
CANDIDATE_STRING
|
||||
S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) "." S( \
|
||||
V8_PATCH_LEVEL) CANDIDATE_STRING
|
||||
#else
|
||||
#define VERSION_STRING \
|
||||
S(MAJOR_VERSION) "." S(MINOR_VERSION) "." S(BUILD_NUMBER) CANDIDATE_STRING
|
||||
S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) \
|
||||
CANDIDATE_STRING
|
||||
#endif
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
int Version::major_ = MAJOR_VERSION;
|
||||
int Version::minor_ = MINOR_VERSION;
|
||||
int Version::build_ = BUILD_NUMBER;
|
||||
int Version::patch_ = PATCH_LEVEL;
|
||||
bool Version::candidate_ = (IS_CANDIDATE_VERSION != 0);
|
||||
int Version::major_ = V8_MAJOR_VERSION;
|
||||
int Version::minor_ = V8_MINOR_VERSION;
|
||||
int Version::build_ = V8_BUILD_NUMBER;
|
||||
int Version::patch_ = V8_PATCH_LEVEL;
|
||||
bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0);
|
||||
const char* Version::soname_ = SONAME;
|
||||
const char* Version::version_string_ = VERSION_STRING;
|
||||
|
||||
|
@ -48,7 +48,7 @@ from git_recipes import GitFailedException
|
||||
CHANGELOG_FILE = "ChangeLog"
|
||||
PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$")
|
||||
PUSH_MSG_NEW_RE = re.compile(r"^Version \d+\.\d+\.\d+$")
|
||||
VERSION_FILE = os.path.join("src", "version.cc")
|
||||
VERSION_FILE = os.path.join("include", "v8-version.h")
|
||||
VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
|
||||
|
||||
# V8 base directory.
|
||||
@ -569,10 +569,10 @@ class Step(GitRecipesMixin):
|
||||
value = match.group(1)
|
||||
self["%s%s" % (prefix, var_name)] = value
|
||||
for line in LinesInFile(os.path.join(self.default_cwd, VERSION_FILE)):
|
||||
for (var_name, def_name) in [("major", "MAJOR_VERSION"),
|
||||
("minor", "MINOR_VERSION"),
|
||||
("build", "BUILD_NUMBER"),
|
||||
("patch", "PATCH_LEVEL")]:
|
||||
for (var_name, def_name) in [("major", "V8_MAJOR_VERSION"),
|
||||
("minor", "V8_MINOR_VERSION"),
|
||||
("build", "V8_BUILD_NUMBER"),
|
||||
("patch", "V8_PATCH_LEVEL")]:
|
||||
ReadAndPersist(var_name, def_name)
|
||||
|
||||
def WaitForLGTM(self):
|
||||
@ -701,16 +701,16 @@ class Step(GitRecipesMixin):
|
||||
def SetVersion(self, version_file, prefix):
|
||||
output = ""
|
||||
for line in FileToText(version_file).splitlines():
|
||||
if line.startswith("#define MAJOR_VERSION"):
|
||||
if line.startswith("#define V8_MAJOR_VERSION"):
|
||||
line = re.sub("\d+$", self[prefix + "major"], line)
|
||||
elif line.startswith("#define MINOR_VERSION"):
|
||||
elif line.startswith("#define V8_MINOR_VERSION"):
|
||||
line = re.sub("\d+$", self[prefix + "minor"], line)
|
||||
elif line.startswith("#define BUILD_NUMBER"):
|
||||
elif line.startswith("#define V8_BUILD_NUMBER"):
|
||||
line = re.sub("\d+$", self[prefix + "build"], line)
|
||||
elif line.startswith("#define PATCH_LEVEL"):
|
||||
elif line.startswith("#define V8_PATCH_LEVEL"):
|
||||
line = re.sub("\d+$", self[prefix + "patch"], line)
|
||||
elif (self[prefix + "candidate"] and
|
||||
line.startswith("#define IS_CANDIDATE_VERSION")):
|
||||
line.startswith("#define V8_IS_CANDIDATE_VERSION")):
|
||||
line = re.sub("\d+$", self[prefix + "candidate"], line)
|
||||
output += "%s\n" % line
|
||||
TextToFile(output, version_file)
|
||||
|
@ -169,12 +169,12 @@ class IncrementVersion(Step):
|
||||
if self._options.revert_master:
|
||||
return
|
||||
new_patch = str(int(self["patch"]) + 1)
|
||||
if self.Confirm("Automatically increment PATCH_LEVEL? (Saying 'n' will "
|
||||
if self.Confirm("Automatically increment V8_PATCH_LEVEL? (Saying 'n' will "
|
||||
"fire up your EDITOR on %s so you can make arbitrary "
|
||||
"changes. When you're done, save the file and exit your "
|
||||
"EDITOR.)" % VERSION_FILE):
|
||||
text = FileToText(os.path.join(self.default_cwd, VERSION_FILE))
|
||||
text = MSub(r"(?<=#define PATCH_LEVEL)(?P<space>\s+)\d*$",
|
||||
text = MSub(r"(?<=#define V8_PATCH_LEVEL)(?P<space>\s+)\d*$",
|
||||
r"\g<space>%s" % new_patch,
|
||||
text)
|
||||
TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE))
|
||||
|
@ -361,12 +361,12 @@ class ScriptTest(unittest.TestCase):
|
||||
with open(version_file, "w") as f:
|
||||
f.write(" // Some line...\n")
|
||||
f.write("\n")
|
||||
f.write("#define MAJOR_VERSION %s\n" % major)
|
||||
f.write("#define MINOR_VERSION %s\n" % minor)
|
||||
f.write("#define BUILD_NUMBER %s\n" % build)
|
||||
f.write("#define PATCH_LEVEL %s\n" % patch)
|
||||
f.write("#define V8_MAJOR_VERSION %s\n" % major)
|
||||
f.write("#define V8_MINOR_VERSION %s\n" % minor)
|
||||
f.write("#define V8_BUILD_NUMBER %s\n" % build)
|
||||
f.write("#define V8_PATCH_LEVEL %s\n" % patch)
|
||||
f.write(" // Some line...\n")
|
||||
f.write("#define IS_CANDIDATE_VERSION 0\n")
|
||||
f.write("#define V8_IS_CANDIDATE_VERSION 0\n")
|
||||
|
||||
def MakeStep(self):
|
||||
"""Convenience wrapper."""
|
||||
@ -528,10 +528,10 @@ class ScriptTest(unittest.TestCase):
|
||||
" too much\n"
|
||||
" trailing", cl)
|
||||
|
||||
self.assertEqual("//\n#define BUILD_NUMBER 3\n",
|
||||
MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
|
||||
self.assertEqual("//\n#define V8_BUILD_NUMBER 3\n",
|
||||
MSub(r"(?<=#define V8_BUILD_NUMBER)(?P<space>\s+)\d*$",
|
||||
r"\g<space>3",
|
||||
"//\n#define BUILD_NUMBER 321\n"))
|
||||
"//\n#define V8_BUILD_NUMBER 321\n"))
|
||||
|
||||
def testPreparePushRevision(self):
|
||||
# Tests the default push hash used when the --revision option is not set.
|
||||
@ -629,7 +629,7 @@ test_tag
|
||||
self.Expect([
|
||||
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
||||
Cmd("git tag", self.TAGS),
|
||||
Cmd("git checkout -f origin/master -- src/version.cc",
|
||||
Cmd("git checkout -f origin/master -- include/v8-version.h",
|
||||
"", cb=lambda: self.WriteFakeVersionFile(3, 22, 6)),
|
||||
])
|
||||
|
||||
@ -750,11 +750,12 @@ Performance and stability improvements on all platforms."""
|
||||
self.assertEquals(commit_msg, commit)
|
||||
version = FileToText(
|
||||
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
|
||||
self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
|
||||
self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
|
||||
self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
|
||||
self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
|
||||
self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
|
||||
self.assertTrue(re.search(r"#define V8_MINOR_VERSION\s+22", version))
|
||||
self.assertTrue(re.search(r"#define V8_BUILD_NUMBER\s+5", version))
|
||||
self.assertFalse(re.search(r"#define V8_BUILD_NUMBER\s+6", version))
|
||||
self.assertTrue(re.search(r"#define V8_PATCH_LEVEL\s+0", version))
|
||||
self.assertTrue(
|
||||
re.search(r"#define V8_IS_CANDIDATE_VERSION\s+0", version))
|
||||
|
||||
# Check that the change log on the candidates branch got correctly
|
||||
# modified.
|
||||
@ -787,7 +788,7 @@ Performance and stability improvements on all platforms."""
|
||||
TEST_CONFIG["BRANCHNAME"]), ""),
|
||||
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
||||
Cmd("git tag", self.TAGS),
|
||||
Cmd("git checkout -f origin/master -- src/version.cc",
|
||||
Cmd("git checkout -f origin/master -- include/v8-version.h",
|
||||
"", cb=self.WriteFakeVersionFile),
|
||||
Cmd("git log -1 --format=%H 3.22.4", "release_hash\n"),
|
||||
Cmd("git log -1 --format=%s release_hash",
|
||||
@ -811,7 +812,7 @@ Performance and stability improvements on all platforms."""
|
||||
Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""),
|
||||
Cmd("git checkout -f origin/candidates -- ChangeLog", "",
|
||||
cb=ResetChangeLog),
|
||||
Cmd("git checkout -f origin/candidates -- src/version.cc", "",
|
||||
Cmd("git checkout -f origin/candidates -- include/v8-version.h", "",
|
||||
cb=self.WriteFakeVersionFile),
|
||||
Cmd("git commit -am \"%s\"" % commit_msg_squashed, ""),
|
||||
]
|
||||
@ -891,11 +892,12 @@ Performance and stability improvements on all platforms."""
|
||||
self.assertEquals(commit_msg, commit)
|
||||
version = FileToText(
|
||||
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
|
||||
self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
|
||||
self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
|
||||
self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
|
||||
self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
|
||||
self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
|
||||
self.assertTrue(re.search(r"#define V8_MINOR_VERSION\s+22", version))
|
||||
self.assertTrue(re.search(r"#define V8_BUILD_NUMBER\s+5", version))
|
||||
self.assertFalse(re.search(r"#define V8_BUILD_NUMBER\s+6", version))
|
||||
self.assertTrue(re.search(r"#define V8_PATCH_LEVEL\s+0", version))
|
||||
self.assertTrue(
|
||||
re.search(r"#define V8_IS_CANDIDATE_VERSION\s+0", version))
|
||||
|
||||
# Check that the change log on the candidates branch got correctly
|
||||
# modified.
|
||||
@ -926,7 +928,7 @@ Performance and stability improvements on all platforms."""
|
||||
"not_right wrong\npending_hash tree_hash\nsome other\n"),
|
||||
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
||||
Cmd("git tag", self.TAGS),
|
||||
Cmd("git checkout -f origin/master -- src/version.cc",
|
||||
Cmd("git checkout -f origin/master -- include/v8-version.h",
|
||||
"", cb=self.WriteFakeVersionFile),
|
||||
Cmd("git log -1 --format=%H 3.22.4", "release_hash\n"),
|
||||
Cmd("git log -1 --format=%s release_hash", "Version 3.22.4\n"),
|
||||
@ -938,7 +940,7 @@ Performance and stability improvements on all platforms."""
|
||||
Cmd("git reset --hard origin/master", ""),
|
||||
Cmd("git checkout -b work-branch pending_hash", ""),
|
||||
Cmd("git checkout -f 3.22.4 -- ChangeLog", "", cb=ResetChangeLog),
|
||||
Cmd("git checkout -f 3.22.4 -- src/version.cc", "",
|
||||
Cmd("git checkout -f 3.22.4 -- include/v8-version.h", "",
|
||||
cb=self.WriteFakeVersionFile),
|
||||
Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
|
||||
cb=CheckVersionCommit),
|
||||
@ -1190,10 +1192,11 @@ LOG=N
|
||||
self.assertEquals(msg, commit)
|
||||
version = FileToText(
|
||||
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
|
||||
self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
|
||||
self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
|
||||
self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version))
|
||||
self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
|
||||
self.assertTrue(re.search(r"#define V8_MINOR_VERSION\s+22", version))
|
||||
self.assertTrue(re.search(r"#define V8_BUILD_NUMBER\s+5", version))
|
||||
self.assertTrue(re.search(r"#define V8_PATCH_LEVEL\s+1", version))
|
||||
self.assertTrue(
|
||||
re.search(r"#define V8_IS_CANDIDATE_VERSION\s+0", version))
|
||||
|
||||
self.Expect([
|
||||
Cmd("git status -s -uno", ""),
|
||||
|
@ -1,246 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2013 the V8 project authors. All rights reserved.
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Tests the push-to-trunk.sh script. Needs to be run in V8 base dir:
|
||||
# ./tools/test-push-to-trunk.sh
|
||||
|
||||
# TODO(machenbach): Check automatically if expectations match.
|
||||
# TODO(machenbach): Mock out version number retrieval.
|
||||
# TODO(machenbach): Allow multiple different test cases.
|
||||
# TODO(machenbach): Allow multi line mock output.
|
||||
# TODO(machenbach): Represent test expectations/mock output without an array
|
||||
# index increment.
|
||||
|
||||
########## Stdin for push-to-trunk.sh
|
||||
|
||||
# Confirm push to trunk commit ID
|
||||
INPUT[0]="Y"
|
||||
# Open editor
|
||||
INPUT[1]=""
|
||||
# Confirm increment version number
|
||||
INPUT[2]="Y"
|
||||
# Reviewer for V8 CL
|
||||
INPUT[3]="reviewer@chromium.org"
|
||||
# Enter LGTM for V8 CL
|
||||
INPUT[4]="LGTM"
|
||||
# Confirm checkout sanity
|
||||
INPUT[5]="Y"
|
||||
# Manually type in trunk revision
|
||||
INPUT[6]="12345"
|
||||
# Reviewer for Chromium CL
|
||||
INPUT[7]="reviewer@chromium.org"
|
||||
|
||||
########## Expected commands and mock output
|
||||
|
||||
EXP[0]="git status -s -uno"
|
||||
OUT[0]=""
|
||||
EXP[1]="git status -s -b -uno"
|
||||
OUT[1]="## some_branch"
|
||||
EXP[2]="git svn fetch"
|
||||
OUT[2]=""
|
||||
EXP[3]="git branch"
|
||||
OUT[3]="not the temp branch"
|
||||
EXP[4]="git checkout -b prepare-push-temporary-branch-created-by-script"
|
||||
OUT[4]=""
|
||||
EXP[5]="git branch"
|
||||
OUT[5]="not the branch"
|
||||
EXP[6]="git branch"
|
||||
OUT[6]="not the trunk branch"
|
||||
EXP[7]="git checkout -b prepare-push svn/bleeding_edge"
|
||||
OUT[7]=""
|
||||
EXP[8]="git log -1 --format=%H ChangeLog"
|
||||
OUT[8]="hash1"
|
||||
EXP[9]="git log -1 hash1"
|
||||
OUT[9]=""
|
||||
EXP[10]="git log hash1..HEAD --format=%H"
|
||||
OUT[10]="hash2"
|
||||
EXP[11]="git log -1 hash2 --format=\"%w(80,8,8)%s\""
|
||||
OUT[11]="Log line..."
|
||||
EXP[12]="git log -1 hash2 --format=\"%B\""
|
||||
OUT[12]="BUG=6789"
|
||||
EXP[13]="git log -1 hash2 --format=\"%w(80,8,8)(%an)\""
|
||||
OUT[13]=" (author@chromium.org)"
|
||||
EXP[14]="git commit -a -m \"Prepare push to trunk. Now working on version 3.4.5.\""
|
||||
OUT[14]=""
|
||||
EXP[15]="git cl upload -r reviewer@chromium.org --send-mail"
|
||||
OUT[15]=""
|
||||
EXP[16]="git cl dcommit"
|
||||
OUT[16]=""
|
||||
EXP[17]="git svn fetch"
|
||||
OUT[17]=""
|
||||
EXP[18]="git checkout svn/bleeding_edge"
|
||||
OUT[18]=""
|
||||
EXP[19]="git log -1 --format=%H --grep=Prepare push to trunk. Now working on version 3.4.5."
|
||||
OUT[19]="hash3"
|
||||
EXP[20]="git diff svn/trunk"
|
||||
OUT[20]="patch1"
|
||||
EXP[21]="git checkout -b trunk-push svn/trunk"
|
||||
OUT[21]=""
|
||||
EXP[22]="git apply --index --reject /tmp/v8-push-to-trunk-tempfile-patch"
|
||||
OUT[22]=""
|
||||
EXP[23]="git add src/version.cc"
|
||||
OUT[23]=""
|
||||
EXP[24]="git commit -F /tmp/v8-push-to-trunk-tempfile-commitmsg"
|
||||
OUT[24]=""
|
||||
EXP[25]="git svn dcommit"
|
||||
OUT[25]="r1234"
|
||||
EXP[26]="git svn tag 3.4.5 -m \"Tagging version 3.4.5\""
|
||||
OUT[26]=""
|
||||
EXP[27]="git status -s -uno"
|
||||
OUT[27]=""
|
||||
EXP[28]="git checkout master"
|
||||
OUT[28]=""
|
||||
EXP[29]="git pull"
|
||||
OUT[29]=""
|
||||
EXP[30]="git checkout -b v8-roll-12345"
|
||||
OUT[30]=""
|
||||
EXP[31]="git commit -am Update V8 to version 3.4.5."
|
||||
OUT[31]=""
|
||||
EXP[32]="git cl upload --send-mail"
|
||||
OUT[32]=""
|
||||
EXP[33]="git checkout -f some_branch"
|
||||
OUT[33]=""
|
||||
EXP[34]="git branch -D prepare-push-temporary-branch-created-by-script"
|
||||
OUT[34]=""
|
||||
EXP[35]="git branch -D prepare-push"
|
||||
OUT[35]=""
|
||||
EXP[36]="git branch -D trunk-push"
|
||||
OUT[36]=""
|
||||
|
||||
########## Global temp files for test input/output
|
||||
|
||||
export TEST_OUTPUT=$(mktemp)
|
||||
export INDEX=$(mktemp)
|
||||
export MOCK_OUTPUT=$(mktemp)
|
||||
export EXPECTED_COMMANDS=$(mktemp)
|
||||
|
||||
########## Command index
|
||||
|
||||
inc_index() {
|
||||
local I="$(command cat $INDEX)"
|
||||
let "I+=1"
|
||||
echo "$I" > $INDEX
|
||||
echo $I
|
||||
}
|
||||
|
||||
echo "-1" > $INDEX
|
||||
export -f inc_index
|
||||
|
||||
########## Mock output accessor
|
||||
|
||||
get_mock_output() {
|
||||
local I=$1
|
||||
let "I+=1"
|
||||
command sed "${I}q;d" $MOCK_OUTPUT
|
||||
}
|
||||
|
||||
export -f get_mock_output
|
||||
|
||||
for E in "${OUT[@]}"; do
|
||||
echo $E
|
||||
done > $MOCK_OUTPUT
|
||||
|
||||
########## Expected commands accessor
|
||||
|
||||
get_expected_command() {
|
||||
local I=$1
|
||||
let "I+=1"
|
||||
command sed "${I}q;d" $EXPECTED_COMMANDS
|
||||
}
|
||||
|
||||
export -f get_expected_command
|
||||
|
||||
for E in "${EXP[@]}"; do
|
||||
echo $E
|
||||
done > $EXPECTED_COMMANDS
|
||||
|
||||
########## Mock commands
|
||||
|
||||
git() {
|
||||
# All calls to git are mocked out. Expected calls and mock output are stored
|
||||
# in the EXP/OUT arrays above.
|
||||
local I=$(inc_index)
|
||||
local OUT=$(get_mock_output $I)
|
||||
local EXP=$(get_expected_command $I)
|
||||
echo "#############################" >> $TEST_OUTPUT
|
||||
echo "Com. Index: $I" >> $TEST_OUTPUT
|
||||
echo "Expected: ${EXP}" >> $TEST_OUTPUT
|
||||
echo "Actual: git $@" >> $TEST_OUTPUT
|
||||
echo "Mock Output: ${OUT}" >> $TEST_OUTPUT
|
||||
echo "${OUT}"
|
||||
}
|
||||
|
||||
mv() {
|
||||
echo "#############################" >> $TEST_OUTPUT
|
||||
echo "mv $@" >> $TEST_OUTPUT
|
||||
}
|
||||
|
||||
sed() {
|
||||
# Only calls to sed * -i * are mocked out.
|
||||
echo "#############################" >> $TEST_OUTPUT
|
||||
local arr=$@
|
||||
if [[ "${arr[@]}" =~ "-i" || "${arr[${#arr[@]}-1]}" == "-i" ]]; then
|
||||
echo "sed $@" >> $TEST_OUTPUT
|
||||
else
|
||||
echo "sed $@" >> $TEST_OUTPUT
|
||||
command sed "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
editor() {
|
||||
echo "#############################" >> $TEST_OUTPUT
|
||||
echo "editor $@" >> $TEST_OUTPUT
|
||||
}
|
||||
|
||||
cd() {
|
||||
echo "#############################" >> $TEST_OUTPUT
|
||||
echo "cd $@" >> $TEST_OUTPUT
|
||||
}
|
||||
|
||||
export -f git
|
||||
export -f mv
|
||||
export -f sed
|
||||
export -f cd
|
||||
export -f editor
|
||||
export EDITOR=editor
|
||||
|
||||
########## Invoke script with test stdin
|
||||
|
||||
for i in "${INPUT[@]}"; do
|
||||
echo $i
|
||||
done | tools/push-to-trunk.sh -c "path/to/chromium"
|
||||
|
||||
echo "Collected output:"
|
||||
command cat $TEST_OUTPUT
|
||||
|
||||
########## Clean up
|
||||
|
||||
rm -rf $TEST_OUTPUT
|
||||
rm -rf $INDEX
|
||||
rm -rf $MOCK_OUTPUT
|
||||
rm -rf $EXPECTED_COMMANDS
|
@ -30,11 +30,11 @@
|
||||
########## Global variable definitions
|
||||
|
||||
BASE_URL="https://code.google.com/p/v8/source/list"
|
||||
VERSION="src/version.cc"
|
||||
MAJOR="MAJOR_VERSION"
|
||||
MINOR="MINOR_VERSION"
|
||||
BUILD="BUILD_NUMBER"
|
||||
PATCH="PATCH_LEVEL"
|
||||
VERSION="include/v8-version.h"
|
||||
MAJOR="V8_MAJOR_VERSION"
|
||||
MINOR="V8_MINOR_VERSION"
|
||||
BUILD="V8_BUILD_NUMBER"
|
||||
PATCH="V8_PATCH_LEVEL"
|
||||
|
||||
V8="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user