[llvm-commits] [zorg] r105976 - in /zorg/trunk/lnt/lnt: testing/util/rcs.py tests/misc/GetSourceVersion tests/nt.py
Daniel Dunbar
daniel at zuster.org
Mon Jun 14 16:41:37 PDT 2010
Author: ddunbar
Date: Mon Jun 14 18:41:37 2010
New Revision: 105976
URL: http://llvm.org/viewvc/llvm-project?rev=105976&view=rev
Log:
LNT/nt: Add (hackish) lnt.testing.util.rcs.get_source_version, instead of being lazy.
Added:
zorg/trunk/lnt/lnt/testing/util/rcs.py
Removed:
zorg/trunk/lnt/lnt/tests/misc/GetSourceVersion
Modified:
zorg/trunk/lnt/lnt/tests/nt.py
Added: zorg/trunk/lnt/lnt/testing/util/rcs.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/rcs.py?rev=105976&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/testing/util/rcs.py (added)
+++ zorg/trunk/lnt/lnt/testing/util/rcs.py Mon Jun 14 18:41:37 2010
@@ -0,0 +1,24 @@
+import os
+from lnt.testing.util import commands
+
+def get_source_version(path):
+ """get_source_version(path) -> str or None
+
+ Given the path to a revision controlled source tree, return a revision
+ number, hash, etc. which identifies the source version.
+ """
+
+ if os.path.exists(os.path.join(path, ".svn")):
+ return commands.capture(['/bin/sh', '-c',
+ 'cd "%s" && svnversion' % path]).strip()
+ elif os.path.exists(os.path.join(path, ".git", "svn")):
+ res = commands.capture(['/bin/sh', '-c',
+ 'cd "%s" && git svn info' % path]).strip()
+ for ln in res.split("\n"):
+ if ln.startswith("Revision:"):
+ return ln.split(':',1)[1].strip()
+ elif os.path.exists(os.path.join(path, ".git")):
+ return commands.capture(['/bin/sh', '-c',
+ ('cd "%s" && '
+ 'git log -1 --pretty=format:%%H') % path]
+ ).strip()
Removed: zorg/trunk/lnt/lnt/tests/misc/GetSourceVersion
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/misc/GetSourceVersion?rev=105975&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/tests/misc/GetSourceVersion (original)
+++ zorg/trunk/lnt/lnt/tests/misc/GetSourceVersion (removed)
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-usage() {
- echo "usage: $0 <source root>"
- echo " Prints the source control revision of the given source directory,"
- echo " the exact format of the revision string depends on the source "
- echo " control system. If the source control system isn't known, the output"
- echo " is empty and the exit code is 1."
- exit 1
-}
-
-if [ $# != 1 ] || [ ! -d $1 ]; then
- usage;
-fi
-
-cd $1
-if [ -d .svn ]; then
- svnversion
-elif [ -d .git/svn ]; then
- git svn info | grep 'Revision:' | cut -d: -f2-
-elif [ -d .git ]; then
- git log -1 --pretty=format:%H
-else
- exit 1;
-fi
-
-exit 0
Modified: zorg/trunk/lnt/lnt/tests/nt.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=105976&r1=105975&r2=105976&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/tests/nt.py (original)
+++ zorg/trunk/lnt/lnt/tests/nt.py Mon Jun 14 18:41:37 2010
@@ -12,10 +12,7 @@
from lnt.testing.util.commands import note, warning, error, fatal
from lnt.testing.util.commands import capture, which
-
-# FIXME: Add util command for this.
-kGetSourceVersionPath = os.path.join(os.path.dirname(__file__),
- 'misc', 'GetSourceVersion')
+from lnt.testing.util.rcs import get_source_version
def timestamp():
return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
@@ -374,12 +371,8 @@
# FIXME: Hack, use better method of getting versions. Ideally, from binaries
# so we are more likely to be accurate.
- run_info['llvm_revision'] = capture([kGetSourceVersionPath,
- opts.llvm_src_root],
- include_stderr=True).strip()
- run_info['test_suite_revision'] = capture([kGetSourceVersionPath,
- opts.test_suite_root],
- include_stderr=True).strip()
+ run_info['llvm_revision'] = get_source_version(opts.llvm_src_root)
+ run_info['test_suite_revision'] = get_source_version(opts.test_suite_root)
run_info.update(public_make_variables)
# Set the run order from the user, if given.
More information about the llvm-commits
mailing list