Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 1150009 - Add cleanup functions to the gaia UI tests that install we... #29834

Merged
merged 1 commit into from
May 20, 2015

Conversation

mwargers
Copy link
Contributor

@mwargers mwargers commented May 1, 2015

...bapps, part 2

@lightsofapollo
Copy link
Contributor

@@ -1055,6 +1054,15 @@ def is_element_displayed(self, by, locator):
def tearDown(self):
if self.device.is_desktop_b2g and self.device.storage_path:
shutil.rmtree(self.device.storage_path, ignore_errors=True)
if self.device.is_android_build:
file_items = self.device.file_manager.list_items('/data/local/webapps/')
dirs_to_keep = ['{14750155-5f3d-41ab-a527-f16adf4c3293}', 'marketplace-dev.allizom.org', 'marketplace.allizom.org', 'marketplace.firefox.com']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one issue here is that some builds put the system apps into /data/local/webapps, so we'd still be deleting them. I really don't like the idea of hardcoding the directories to keep. Looking at /data/local/webapps/webapps.json is appears that we could identify the apps to delete using "removable": true. Could you try a patch that reads in that file, identifies the removable apps and deletes them from the filesystem using "basePath" and the main key? Also, I'd like to move this back into setUp so our cleanup is all in the same place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that "removable": true also applies to the Mochitest and Marketplace apps, so I don't think we can use that. Perhaps there's something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like all bundled apps have the same installTime, so we could get the value from an expected app (such as the homescreen), and delete any app that has a greater value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for looking into it, I'll try the installTime trick for this, then.

@lightsofapollo
Copy link
Contributor

break
if delete_file and self.device.file_manager.dir_exists('/data/local/webapps/' + dir):
self.device.file_manager.remove('/data/local/webapps/' + dir)
print('deleting dir for: ' + dir + ':: ' + str(apps[app]['installTime']))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to list the items in /data/local/webapps as we should be able to extract that from the basePath from the JSON file. I haven't tested it, but the following should work:

apps = json.loads(self.device.file_manager.pull_file('/data/local/webapps/webapps.json'))
system_install_time = apps['system.gaiamobile.org']['installTime']
for app in apps.values():
    if app.get('installTime') > system_install_time:
        # removing any webapps installed since build time
        path = posixpath.join(app.get('basePath'), app.get('id')
        self.logger.debug('Removing %s' % path)
        self.device.file_manager.remove(path)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that works. I was afraid this wouldn't catch webapps that wouldn't be listed in the webapps.json file, for some reason, but it seems that doesn't happen (I thought it did, at some point).

@lightsofapollo
Copy link
Contributor

@lightsofapollo
Copy link
Contributor

mwargers added a commit that referenced this pull request May 20, 2015
Bug 1150009 - Add cleanup functions to the gaia UI tests that install we...
@mwargers mwargers merged commit 252c00c into mozilla-b2g:master May 20, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants