GoogleCloudPlatform / endpoints-proto-datastore

Apache License 2.0
154 stars 52 forks source link

test_utils.which('dev_appserver.py') only returns one path #130

Open medullaskyline opened 9 years ago

medullaskyline commented 9 years ago

It looks like there are two dev_appserver.py files now in the google-cloud-sdk directory and the one with the fix_sys_path() is located in: google_appengine/dev_appserver.py. (Referenced from this issue.)

Since that's the case, shouldn't test_utils.which return a list of potential paths instead of a string with only one path? It seems that was the original intent of the code. As it is, depending on the order of entries in $PATH, the test runner could only return the path to the dev_appserver.py file that doesn't have fix_sys_path().

dhermes commented 9 years ago

If you run which in bash (or another *nix shell) you'll see:

$ which dev_appserver.py
.../google-cloud-sdk/bin/dev_appserver.py

The other dev_appserver.py is just an import-able module, not an actual binary and has been shipped with the SDK since before test_utils.which was written.

medullaskyline commented 9 years ago

Yes, and the file .../google-cloud-sdk/bin/dev_appserver.py looks like this...

#!/usr/bin/env python
#
# Copyright 2013 Google Inc. All Rights Reserved.
#

"""A convenience wrapper for starting dev_appserver for appengine for python."""

import os

import bootstrapping.bootstrapping as bootstrapping

from googlecloudsdk.core.util import platforms

def main():
  """Launches dev_appserver.py."""

  args = [
      '--skip_sdk_update_check=True'
  ]
  if platforms.OperatingSystem.Current() == platforms.OperatingSystem.MACOSX:
    php_path = os.path.join(bootstrapping.BOOTSTRAPPING_DIR, 'php-cgi')
    if os.path.exists(php_path):
      args.append('--php_executable_path=' + php_path)
  # The executable for Windows will be in the correct default location.

  bootstrapping.ExecutePythonTool(
      'platform/google_appengine', 'dev_appserver.py', *args)

if __name__ == '__main__':
  bootstrapping.CommandStart('dev_appserver', component_id='gae-python')
  bootstrapping.CheckUpdates()
  main()

...which doesn't have fix_sys_path(), something that's in the test runner. Correct me if I'm missing something. :)

dhermes commented 9 years ago

Ahhhh good call! I just checked and it appears the test runner doesn't work.

  1. It's unclear why I didn't just use tox.
  2. I have more recently hacked a working version of this for oauth2client.
  3. Unfortunately, testing isn't at all comprehensive.