Fix --version in drive programs

Fixes #176

Change-Id: Ib092f81e1af49dfee43f7b01c0008a1b40c9098b
This commit is contained in:
Kongqun Yang 2016-12-08 12:07:09 -08:00
parent eab7910029
commit c8ffa54d35
4 changed files with 11 additions and 18 deletions

View File

@ -97,14 +97,13 @@ int MpdMain(int argc, char** argv) {
log_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; log_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
CHECK(logging::InitLogging(log_settings)); CHECK(logging::InitLogging(log_settings));
google::SetVersionString(GetPackagerVersion());
google::SetUsageMessage(base::StringPrintf(kUsage, argv[0])); google::SetUsageMessage(base::StringPrintf(kUsage, argv[0]));
google::ParseCommandLineFlags(&argc, &argv, true); google::ParseCommandLineFlags(&argc, &argv, true);
ExitStatus status = CheckRequiredFlags(); ExitStatus status = CheckRequiredFlags();
if (status != kSuccess) { if (status != kSuccess) {
const std::string version_string = base::StringPrintf( google::ShowUsageWithFlags("Usage");
"mpd_generator version %s", GetPackagerVersion().c_str());
google::ShowUsageWithFlags(version_string.c_str());
return status; return status;
} }

View File

@ -72,8 +72,7 @@ namespace media {
namespace { namespace {
const char kUsage[] = const char kUsage[] =
"Packager driver program. Usage:\n\n" "%s [flags] <stream_descriptor> ...\n\n"
"%s [flags] <stream_descriptor> ...\n"
" stream_descriptor consists of comma separated field_name/value pairs:\n" " stream_descriptor consists of comma separated field_name/value pairs:\n"
" field_name=value,[field_name=value,]...\n" " field_name=value,[field_name=value,]...\n"
" Supported field names are as follows:\n" " Supported field names are as follows:\n"
@ -525,12 +524,11 @@ int PackagerMain(int argc, char** argv) {
log_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; log_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
CHECK(logging::InitLogging(log_settings)); CHECK(logging::InitLogging(log_settings));
google::SetVersionString(GetPackagerVersion());
google::SetUsageMessage(base::StringPrintf(kUsage, argv[0])); google::SetUsageMessage(base::StringPrintf(kUsage, argv[0]));
google::ParseCommandLineFlags(&argc, &argv, true); google::ParseCommandLineFlags(&argc, &argv, true);
if (argc < 2) { if (argc < 2) {
const std::string version_string = base::StringPrintf( google::ShowUsageWithFlags("Usage");
"shaka-packager version %s", GetPackagerVersion().c_str());
google::ShowUsageWithFlags(version_string.c_str());
return kSuccess; return kSuccess;
} }

View File

@ -31,11 +31,7 @@ class PackagerApp(object):
return subprocess.check_output(cmd) return subprocess.check_output(cmd)
def Version(self): def Version(self):
output = subprocess.check_output([self.binary]) return subprocess.check_output([self.binary, '--version'])
# The output should of the form:
# shaka-packager version xxx: Description...
# We consider everything before ':' part of version.
return output.split(':')[0]
def Package(self, streams, flags=None): def Package(self, streams, flags=None):
if flags is None: if flags is None:

View File

@ -39,8 +39,8 @@ class PackagerAppTest(unittest.TestCase):
def testVersion(self): def testVersion(self):
self.assertRegexpMatches( self.assertRegexpMatches(
self.packager.Version(), '^shaka-packager version ' self.packager.Version(), '^packager version '
r'((?P<tag>[\w\.]+)-)?(?P<hash>[a-f\d]+)-(debug|release)$') r'((?P<tag>[\w\.]+)-)?(?P<hash>[a-f\d]+)-(debug|release)\n.*$')
def testDumpStreamInfo(self): def testDumpStreamInfo(self):
test_file = os.path.join(self.test_data_dir, 'bear-640x360.mp4') test_file = os.path.join(self.test_data_dir, 'bear-640x360.mp4')