testing/moztesting/util.py
author Peter Van der Beken <peterv@propagandism.org>
Thu, 06 Dec 2012 11:41:14 +0100
changeset 120775 f23cff8ec6c9ab4cac0c4582967647140855a625
parent 114430 cff221895afe122f2bb51224d369e6d26509dfad
child 127905 d01bf199fcbacb932347767aa3023d73759020a1
permissions -rw-r--r--
Fix for bug 818219 (Replace HTMLElement quickstubs with new binding methods) - Add a constructor to callbacks to allow conversion between callback types. r=bz.

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import unicode_literals

import os


def parse_test_path(test_path, topsrcdir):
    """Returns a dict containing:
    * 'normalized': the normalized path, relative to the topsrcdir
    * 'isdir': whether the path points to a directory
    """
    is_dir = os.path.isdir(test_path)

    if is_dir and not test_path.endswith(os.path.sep):
        test_path += os.path.sep

    normalized = test_path

    if test_path.startswith(topsrcdir):
        normalized = test_path[len(topsrcdir):]

    return {
        'normalized': normalized,
        'is_dir': is_dir,
    }