Do parse checks after pass-through args have been populated.

Fix bug introduced by https://gerrit.chromium.org/gerrit/#/c/23599/.
Added regression unit test.

BUG=None
TEST=unit testing, local.

Change-Id: I85b3bbb4b7a959b3203c14c4e9c45bcd8ef89021
Reviewed-on: https://gerrit.chromium.org/gerrit/37978
Commit-Ready: Ryan Cui <rcui@chromium.org>
Reviewed-by: Ryan Cui <rcui@chromium.org>
Tested-by: Ryan Cui <rcui@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 5cd387d..b808dba 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -10,7 +10,6 @@
 full and pre-flight-queue builds.
 """
 
-import collections
 import distutils.version
 import glob
 import logging
@@ -931,6 +930,10 @@
   Args:
     options, args: The options/args object returned by optparse
   """
+  # Populate options.pass_through_args.
+  accepted, _ = commandline.FilteringParser.FilterArgs(
+      options.parsed_args, lambda x: x.opt_inst.pass_through)
+  options.pass_through_args.extend(accepted)
 
   if options.chrome_root:
     if options.chrome_rev != constants.CHROME_REV_LOCAL:
@@ -1005,11 +1008,6 @@
     #    repo.
     options.debug = not options.buildbot and not options.remote
 
-  # Populate options.pass_through_args.
-  accepted, _ = commandline.FilteringParser.FilterArgs(
-      options.parsed_args, lambda x: x.opt_inst.pass_through)
-  options.pass_through_args.extend(accepted)
-
   # Record the configs targeted.
   options.build_targets = args[:]