Exemple #1
0
    def test_find_multiple_configs(self):
        """Ensure multiple relative-path MOZCONFIGs result in error."""
        relative_mozconfig = '.mconfig'
        os.environ[b'MOZCONFIG'] = relative_mozconfig

        srcdir = self.get_temp_dir()
        curdir = self.get_temp_dir()
        dirs = [srcdir, curdir]
        loader = MozconfigLoader(srcdir)
        for d in dirs:
            path = os.path.join(d, relative_mozconfig)
            with open(path, 'wb') as f:
                f.write(path)

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            with self.assertRaises(MozconfigFindException) as e:
                loader.find_mozconfig()
        finally:
            os.chdir(orig_dir)

        self.assertIn('exists in more than one of', e.exception.message)
        for d in dirs:
            self.assertIn(d, e.exception.message)
    def test_find_multiple_configs(self):
        """Ensure multiple relative-path MOZCONFIGs result in error."""
        relative_mozconfig = '.mconfig'
        os.environ[b'MOZCONFIG'] = relative_mozconfig

        srcdir = self.get_temp_dir()
        curdir = self.get_temp_dir()
        dirs = [srcdir, curdir]
        loader = MozconfigLoader(srcdir)
        for d in dirs:
            path = os.path.join(d, relative_mozconfig)
            with open(path, 'wb') as f:
                f.write(path)

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            with self.assertRaises(MozconfigFindException) as e:
                loader.find_mozconfig()
        finally:
            os.chdir(orig_dir)

        self.assertIn('exists in more than one of', e.exception.message)
        for d in dirs:
            self.assertIn(d, e.exception.message)
Exemple #3
0
def autoconf_refresh(configure):
    if os.path.exists(configure):
        mtime = os.path.getmtime(configure)
        aclocal = os.path.join(base_dir, 'build', 'autoconf', '*.m4')
        for input in itertools.chain(
            (configure + '.in',
             os.path.join(os.path.dirname(configure), 'aclocal.m4')),
                glob.iglob(aclocal),
        ):
            if os.path.getmtime(input) > mtime:
                break
        else:
            return

    mozconfig_autoconf = None
    configure_dir = os.path.dirname(configure)
    # Don't read the mozconfig for the js configure (yay backwards
    # compatibility)
    if not configure_dir.replace(os.sep, '/').endswith('/js/src'):
        loader = MozconfigLoader(os.path.dirname(configure))
        project = os.environ.get('MOZ_CURRENT_PROJECT')
        mozconfig = loader.find_mozconfig(env=os.environ)
        mozconfig = loader.read_mozconfig(mozconfig, moz_build_app=project)
        make_extra = mozconfig['make_extra']
        if make_extra:
            for assignment in make_extra:
                m = re.match('(?:export\s+)?AUTOCONF\s*:?=\s*(.+)$',
                             assignment)
                if m:
                    mozconfig_autoconf = m.group(1)

    for ac in (mozconfig_autoconf, os.environ.get('AUTOCONF'), 'autoconf-2.13',
               'autoconf2.13', 'autoconf213'):
        if ac:
            autoconf = find_program(ac)
            if autoconf:
                break
    else:
        fink = find_program('fink')
        if fink:
            autoconf = os.path.normpath(
                os.path.join(fink, '..', '..', 'lib', 'autoconf2.13', 'bin',
                             'autoconf'))

    if not autoconf:
        raise RuntimeError('Could not find autoconf 2.13')

    # Add or adjust AUTOCONF for subprocesses, especially the js/src configure
    os.environ['AUTOCONF'] = autoconf

    print('Refreshing %s with %s' % (configure, autoconf), file=sys.stderr)

    with open(configure, 'wb') as fh:
        subprocess.check_call([
            shell, autoconf,
            '--localdir=%s' % os.path.dirname(configure), configure + '.in'
        ],
                              stdout=fh)
Exemple #4
0
def autoconf_refresh(configure):
    if os.path.exists(configure):
        mtime = os.path.getmtime(configure)
        aclocal = os.path.join(base_dir, 'build', 'autoconf', '*.m4')
        for input in itertools.chain(
            (configure + '.in',
             os.path.join(os.path.dirname(configure), 'aclocal.m4')),
            glob.iglob(aclocal),
        ):
            if os.path.getmtime(input) > mtime:
                break
        else:
            return

    mozconfig_autoconf = None
    configure_dir = os.path.dirname(configure)
    # Don't read the mozconfig for the js configure (yay backwards
    # compatibility)
    if not configure_dir.replace(os.sep, '/').endswith('/js/src'):
        loader = MozconfigLoader(os.path.dirname(configure))
        project = os.environ.get('MOZ_CURRENT_PROJECT')
        mozconfig = loader.find_mozconfig(env=os.environ)
        mozconfig = loader.read_mozconfig(mozconfig, moz_build_app=project)
        make_extra = mozconfig['make_extra']
        if make_extra:
            for assignment in make_extra:
                m = re.match('(?:export\s+)?AUTOCONF\s*:?=\s*(.+)$',
                             assignment)
                if m:
                    mozconfig_autoconf = m.group(1)

    for ac in (mozconfig_autoconf, os.environ.get('AUTOCONF'), 'autoconf-2.13',
               'autoconf2.13', 'autoconf213'):
        if ac:
            autoconf = find_program(ac)
            if autoconf:
                break
    else:
        fink = find_program('fink')
        if fink:
            autoconf = os.path.normpath(os.path.join(
                fink, '..', '..', 'lib', 'autoconf2.13', 'bin', 'autoconf'))

    if not autoconf:
        raise RuntimeError('Could not find autoconf 2.13')

    # Add or adjust AUTOCONF for subprocesses, especially the js/src configure
    os.environ['AUTOCONF'] = autoconf

    print('Refreshing %s with %s' % (configure, autoconf), file=sys.stderr)

    with open(configure, 'wb') as fh:
        subprocess.check_call([
            shell, autoconf, '--localdir=%s' % os.path.dirname(configure),
            configure + '.in'], stdout=fh)
    def test_find_no_relative_configs(self):
        """Ensure a missing relative-path MOZCONFIG is detected."""
        relative_mozconfig = '.mconfig'
        os.environ[b'MOZCONFIG'] = relative_mozconfig

        srcdir = self.get_temp_dir()
        curdir = self.get_temp_dir()
        dirs = [srcdir, curdir]
        loader = MozconfigLoader(srcdir)

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            with self.assertRaises(MozconfigFindException) as e:
                loader.find_mozconfig()
        finally:
            os.chdir(orig_dir)

        self.assertIn('does not exist in any of', e.exception.message)
        for d in dirs:
            self.assertIn(d, e.exception.message)
Exemple #6
0
    def test_find_no_relative_configs(self):
        """Ensure a missing relative-path MOZCONFIG is detected."""
        relative_mozconfig = '.mconfig'
        os.environ[b'MOZCONFIG'] = relative_mozconfig

        srcdir = self.get_temp_dir()
        curdir = self.get_temp_dir()
        dirs = [srcdir, curdir]
        loader = MozconfigLoader(srcdir)

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            with self.assertRaises(MozconfigFindException) as e:
                loader.find_mozconfig()
        finally:
            os.chdir(orig_dir)

        self.assertIn('does not exist in any of', e.exception.message)
        for d in dirs:
            self.assertIn(d, e.exception.message)
    def test_find_relative_mozconfig(self):
        """Ensure a relative MOZCONFIG can be found in the srcdir."""
        relative_mozconfig = '.mconfig'
        os.environ[b'MOZCONFIG'] = relative_mozconfig

        srcdir = self.get_temp_dir()
        curdir = self.get_temp_dir()
        loader = MozconfigLoader(srcdir)

        path = os.path.join(srcdir, relative_mozconfig)
        with open(path, 'w'):
            pass

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            self.assertEqual(os.path.normpath(loader.find_mozconfig()),
                             os.path.normpath(path))
        finally:
            os.chdir(orig_dir)
Exemple #8
0
    def test_find_relative_mozconfig(self):
        """Ensure a relative MOZCONFIG can be found in the srcdir."""
        relative_mozconfig = ".mconfig"
        os.environ[b"MOZCONFIG"] = relative_mozconfig

        srcdir = self.get_temp_dir()
        curdir = self.get_temp_dir()
        dirs = [srcdir, curdir]
        loader = MozconfigLoader(srcdir)

        path = os.path.join(srcdir, relative_mozconfig)
        with open(path, "w"):
            pass

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            self.assertEqual(os.path.normpath(loader.find_mozconfig()), os.path.normpath(path))
        finally:
            os.chdir(orig_dir)
Exemple #9
0
    def test_find_multiple_but_identical_configs(self):
        """Ensure multiple relative-path MOZCONFIGs pointing at the same file are OK."""
        relative_mozconfig = "../src/.mconfig"
        os.environ[b"MOZCONFIG"] = relative_mozconfig

        topdir = self.get_temp_dir()
        srcdir = os.path.join(topdir, "src")
        os.mkdir(srcdir)
        curdir = os.path.join(topdir, "obj")
        os.mkdir(curdir)

        loader = MozconfigLoader(srcdir)
        path = os.path.join(srcdir, relative_mozconfig)
        with open(path, "w"):
            pass

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            self.assertEqual(os.path.realpath(loader.find_mozconfig()), os.path.realpath(path))
        finally:
            os.chdir(orig_dir)
Exemple #10
0
    def test_find_multiple_but_identical_configs(self):
        """Ensure multiple relative-path MOZCONFIGs pointing at the same file are OK."""
        relative_mozconfig = '../src/.mconfig'
        os.environ[b'MOZCONFIG'] = relative_mozconfig

        topdir = self.get_temp_dir()
        srcdir = os.path.join(topdir, 'src')
        os.mkdir(srcdir)
        curdir = os.path.join(topdir, 'obj')
        os.mkdir(curdir)

        loader = MozconfigLoader(srcdir)
        path = os.path.join(srcdir, relative_mozconfig)
        with open(path, 'w'):
            pass

        orig_dir = os.getcwd()
        try:
            os.chdir(curdir)
            self.assertEqual(os.path.realpath(loader.find_mozconfig()),
                             os.path.realpath(path))
        finally:
            os.chdir(orig_dir)