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;
CHECK(logging::InitLogging(log_settings));
google::SetVersionString(GetPackagerVersion());
google::SetUsageMessage(base::StringPrintf(kUsage, argv[0]));
google::ParseCommandLineFlags(&argc, &argv, true);
ExitStatus status = CheckRequiredFlags();
if (status != kSuccess) {
const std::string version_string = base::StringPrintf(
"mpd_generator version %s", GetPackagerVersion().c_str());
google::ShowUsageWithFlags(version_string.c_str());
google::ShowUsageWithFlags("Usage");
return status;
}

View File

@ -72,8 +72,7 @@ namespace media {
namespace {
const char kUsage[] =
"Packager driver program. Usage:\n\n"
"%s [flags] <stream_descriptor> ...\n"
"%s [flags] <stream_descriptor> ...\n\n"
" stream_descriptor consists of comma separated field_name/value pairs:\n"
" field_name=value,[field_name=value,]...\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;
CHECK(logging::InitLogging(log_settings));
google::SetVersionString(GetPackagerVersion());
google::SetUsageMessage(base::StringPrintf(kUsage, argv[0]));
google::ParseCommandLineFlags(&argc, &argv, true);
if (argc < 2) {
const std::string version_string = base::StringPrintf(
"shaka-packager version %s", GetPackagerVersion().c_str());
google::ShowUsageWithFlags(version_string.c_str());
google::ShowUsageWithFlags("Usage");
return kSuccess;
}

View File

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

View File

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