Closed Bug 717408 Opened 10 years ago Closed 10 years ago

Invalid syntax error when trying to run robotium tests

Categories

(Testing :: Mochitest, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
mozilla12

People

(Reporter: martijn.martijn, Assigned: kats)

Details

Attachments

(1 file)

I tried to run the robotium tests, but I'm getting this error.

macbook-pro-van-martijn-wargers:objdir-droid mw22$ MOZ_HOST_BIN="~/mozilla-build/native/objdir-droid/dist/bin/" make mochitest-robotium
Traceback (most recent call last):
  File "_tests/testing/mochitest/runtestsremote.py", line 51, in <module>
    import devicemanager, devicemanagerADB, devicemanagerSUT
  File "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/devicemanagerADB.py", line 581
    except Exception as (ex):
                      ^
SyntaxError: invalid syntax
make: *** [mochitest-robotium] Error 1


Kats helped me investigate a little bit.
My .bash_profile file consists this: export PATH=~/android-sdk-macosx/platform-tools/:$PATH
I verified that I can run adb just fine.

This is my .mozconfig file:
# Add the correct paths here:
ac_add_options --with-android-ndk="$HOME/android-ndk-r6b"
ac_add_options --with-android-toolchain="$HOME/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86"
ac_add_options --with-android-platform="$HOME/android-ndk-r6b/platforms/android-8/arch-arm"
ac_add_options --with-android-tools="$HOME/android-sdk-mac_x86/tools"
ac_add_options --with-android-sdk="$HOME/android-sdk-macosx/platforms/android-13"
ac_add_options --with-android-version=8

# android options
ac_add_options --enable-debug
ac_add_options --disable-optimize
#ac_add_options --with-ccache
ac_add_options --disable-crashreporter

mk_add_options MOZ_OBJDIR=./objdir-droid
mk_add_options MOZ_MAKE_FLAGS="-j16 -s"

# Android options
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi

I followed these instructions:
https://wiki.mozilla.org/Mobile/Fennec/Android#Robotium
(In reply to Martijn Wargers [:mw22] (QA - IRC nick: mw22) from comment #0)

What version of python do you have? "python -V" should say.
Python 2.7.2
I googled this a bit and found this: http://www.gossamer-threads.com/lists/python/python/785327 which explains why you were seeing it originally running python 2.5. However with 2.7 it should work fine. Can you verify that after upgrading to 2.7 that's the actual version that's getting picked up? It's possible that somehow the old version is still being used by the build scripts, although I'm not sure how to check that.
Seems like this should do the trick. I haven't actually tested it because my build is hosed right now (bug 717441) but I will try it soon.
Attachment #588032 - Flags: review?(gbrown)
After applying that patch directly to "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/devicemanagerADB.py", line 581
I get this error:

macbook-pro-van-martijn-wargers:objdir-droid mw22$ TEST_PATH=gfx MOZ_HOST_BIN="~/mozilla-build/native/objdir-droid/dist/bin/" make mochitest-remote
unable to execute 'cp' on device; consider installing busybox from Android Market
error: device not found
INFO | runtests.py | Installing extension at /Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/extensions/roboextender@mozilla.org to /var/folders/8s/8sdX2oOVFBeT-2FhAqOytE+++TI/-Tmp-/tmp_qFeSz.
INFO | runtests.py | Installing extension at /Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/extensions/specialpowers to /var/folders/8s/8sdX2oOVFBeT-2FhAqOytE+++TI/-Tmp-/tmp_qFeSz.
INFO | runtests.py | Installing extension at /Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/extensions/worker to /var/folders/8s/8sdX2oOVFBeT-2FhAqOytE+++TI/-Tmp-/tmp_qFeSz.
INFO | runtests.py | Installing extension at /Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/extensions/workerbootstrap to /var/folders/8s/8sdX2oOVFBeT-2FhAqOytE+++TI/-Tmp-/tmp_qFeSz.
pushing /var/folders/8s/8sdX2oOVFBeT-2FhAqOytE+++TI/-Tmp-/tmp_qFeSz to /data/local/tests/profile failed
TEST-UNEXPECTED-ERROR | | Exception caught while running tests.
Traceback (most recent call last):
  File "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/runtestsremote.py", line 426, in <module>
    main()
  File "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/runtestsremote.py", line 419, in main
    mochitest.stopWebServer(options)
  File "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/runtestsremote.py", line 297, in stopWebServer
    self.server.stop()
AttributeError: 'MochiRemote' object has no attribute 'server'
make: *** [mochitest-remote] Error 1
macbook-pro-van-martijn-wargers:objdir-droid mw22$ MOZ_HOST_BIN="~/mozilla-build/native/objdir-droid/dist/bin/" make mochitest-robotium
unable to execute 'cp' on device; consider installing busybox from Android Market
error: device not found
error: device not found
error: device not found
error: device not found
Traceback (most recent call last):
  File "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/runtestsremote.py", line 426, in <module>
    main()
  File "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/runtestsremote.py", line 395, in main
    dm.checkCmd(["install", "-r", os.path.join(options.robocopPath, "robocop.apk")])
  File "/Users/mw22/mozilla-build/native/objdir-droid/_tests/testing/mochitest/devicemanagerADB.py", line 554, in checkCmd
    return subprocess.check_call(args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/subprocess.py", line 461, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['adb', 'install', '-r', '/Users/mw22/mozilla-build/native/objdir-droid/build/mobile/robocop/robocop.apk']' returned non-zero exit status 1
make: *** [mochitest-robotium] Error 1
(In reply to Kartikaya Gupta (:kats) from comment #4)
> Seems like this should do the trick. I haven't actually tested it because my
> build is hosed right now (bug 717441) but I will try it soon.

Tried it, verified it still works for me (python 2.7.1)
From discussion on irc...the "device not found" in comment 5 was because adb could not see the device. "adb devices" showed nothing attached.
Comment on attachment 588032 [details] [diff] [review]
Remove "as" clause

Review of attachment 588032 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good. Thanks kats!
Attachment #588032 - Flags: review?(gbrown) → review+
https://hg.mozilla.org/mozilla-central/rev/37b69f47d522
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla12
Assignee: nobody → bugmail.mozilla
Ok, thanks for fixing. I'm not stuck anymore with this error. Now, I crash on startup, because my debug Fennec build is crashing on startup. I filed bug 719985 for that.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.