<commit_before>#!/usr/bin/env python
#
# 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/.

import os
import sys

path0 = os.path.dirname(os.path.abspath(__file__))
path1 = os.path.abspath(os.path.join(path0, os.pardir, 'util'))
sys.path.append(path1)
from subprocesses import isARMv7l, isMac, isMozBuild64, isWin, isWin64, macVer

def hgrange(firstBad, firstGood):
    """Like "firstBad::firstGood", but includes branches/csets that never got the firstGood fix."""
    # NB: mercurial's descendants(x) includes x
    # So this revset expression includes firstBad, but does not include firstGood.
    # NB: hg log -r "(descendants(id(badddddd)) - descendants(id(baddddddd)))" happens to return the empty set, like we want"
    return '(descendants(id(' + firstBad + '))-descendants(id(' + firstGood + ')))'

def knownBrokenRangesBrowser(options):
    skips = [
        hgrange('cc45fdc389df', 'e8938a43c31a'), # Builds with --disable-crashreporter were broken (see bug 779291)
        hgrange('19f154ee6f54', 'd97ecf9f9b84'), # Backed out for bustage
        hgrange('eaa88688e9e8', '7a7e1ca619c2'), # Missing include (affected Jesse's MBP but not Tinderbox)
        hgrange('fbc1e196ca87', '7a9887e1f55e'), # Quick followup for bustage
        hgrange('bfef9b308f92', '991938589ebe'), # A landing required a build fix and a startup-assertion fix
        hgrange('b6dc96f18391', '37e29c27e6e8'), # Duplicate symbols with 10.9 SDK, between ICU being built by default and a bug being fixed
        hgrange('ad70d9583d42', 'd0f501b227fc'), # Short bustage
        hgrange('c5906eed61fc', '1c4ac1d21d29'), # Builds succeed but die early in startup
    ]

    return skips

def knownBrokenRanges(options):
    '''Returns a list of revsets corresponding to known-busted revisions'''
    # Paste numbers into: https://hg.mozilla.org/mozilla-central/rev/<number> to get hgweb link.
    # To add to the list:
    # - (1) will tell you when the brokenness started
    # - (1) autoBisect.py --compilationFailedLabel=bad -e FAILINGREV
    # - (2) will tell you when the brokenness ended
    # - (2) autoBisect.py --compilationFailedLabel=bad -s FAILINGREV

    # ANCIENT FIXME: It might make sense to avoid (or note) these in checkBlameParents.

    skips = [
        hgrange('d633e3ff2013', 'bcbe93f41547'), # Fx29, broken non-threadsafe
        hgrange('dbeea0e93b56', 'b980c2dee2e7'), # Fx29, broken non-threadsafe
        hgrange('995f7402235b', '6c899a1064f3'), # Fx30, broken non-threadsafe
        hgrange('d2c4ae312b66', 'abfaf0ccae19'), # Fx30, broken non-threadsafe
        hgrange('7cff27cb2845', 'ff5ca7959511'), # Fx30, broken build config w/ NSPR
        hgrange('07c0cf637290', 'f2adbe2a41c0'), # Fx31, broken non-threadsafe
        hgrange('99a6ee6466f5', '5c9119729bbf'), # Fx32, unstable spidermonkey
        hgrange('93dce4b831f3', '143ce643d1b3'), # Fx32, asserts when run with --thread-count=1
        hgrange('573458d10426', '5a50315d4d7d'), # Fx33, broken non-threadsafe
        hgrange('6b285759568c', 'e498b157651e'), # Fx34, broken ICU
        hgrange('03242a11d044', '31714af41f2c'), # Fx35, broken spidermonkey due to let changes
    ]

    if isARMv7l:
        skips.extend([
            hgrange('688d526f9313', '280aa953c868'), # Fx29-30, broken ARM builds
            hgrange('35e7af3e86fd', 'a393ec07bc6a'), # Fx32, broken ARM builds
        ])

    if isWin:
        skips.extend([
            hgrange('f6d5a48271b6', 'dc128b242d8a'), # Fx29, broken Windows builds due to ICU
            hgrange('17c463691232', 'f76b7bc18dbc'), # Fx29-30, build breakage
            hgrange('d959285c827e', 'edf5e2dc9198'), # Fx33, build breakage
        ])

    if isMozBuild64:
        skips.extend([
            hgrange('77d06ee9ac48', 'e7bb99d245e8'), # Fx28-29, breakage due to moz.build error
        ])

    if options.enableMoreDeterministic:
        skips.extend([
            hgrange('4a04ca5ed7d3', '406904577dfc'), # Fx33, see bug 1030014
            hgrange('752ce35b166b', 'e6e63113336d'), # Fx35, see bug 1069704
        ])

    return skips

def earliestKnownWorkingRevForBrowser(options):
    if isMac and macVer() >= [10, 9]:
        return '1c4ac1d21d29' # beacc621ec68 fixed 10.9 builds, but landed in the middle of unrelated bustage
    return '4e852ca66ea0' # or 'd97862fb8e6d' (same as js below) ... either way, oct 2012 on mac :(

def earliestKnownWorkingRev(options, flags, skipRevs):
    '''
    Returns a revset which evaluates to the first revision of the shell that
    compiles with |options| and runs jsfunfuzz successfully with |flags|.
    '''
    assert (not isMac) or (macVer() >= [10, 7])  # Only Lion and above are supported with Clang 4.

    # These should be in descending order, or bisection will break at earlier changesets.

    offthreadCompileFlag = asmNopFillFlag = asmPoolMaxOffsetFlag = False
    # flags is a list of flags, and the option must exactly match.
    for entry in flags:
        # What comes after these flags needs to be a number, so we look for the string instead.
        if '--ion-offthread-compile=' in entry:
            offthreadCompileFlag = True
        elif '--arm-asm-nop-fill=' in entry:
            asmNopFillFlag = True
        elif '--asm-pool-max-offset=' in entry:
            asmPoolMaxOffsetFlag = True

    required = []

    if '--no-threads' in flags:
        required.append('e8558ecd9b16') # m-c 195999 Fx34, 1st w/--no-threads, see bug 1031529
    if isWin64 or '--enable-nspr-build' in flags:  # Win64 has peculiar complexities prior to this<commit_msg>Oops, --enable-nspr-build is a compile-time flag, not a run-time one, so detect this properly in autobisect-js/knownBrokenEarliestWorking.py.<commit_after>#!/usr/bin/env python
#
# 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/.

import os
import sys

path0 = os.path.dirname(os.path.abspath(__file__))
path1 = os.path.abspath(os.path.join(path0, os.pardir, 'util'))
sys.path.append(path1)
from subprocesses import isARMv7l, isMac, isMozBuild64, isWin, isWin64, macVer

def hgrange(firstBad, firstGood):
    """Like "firstBad::firstGood", but includes branches/csets that never got the firstGood fix."""
    # NB: mercurial's descendants(x) includes x
    # So this revset expression includes firstBad, but does not include firstGood.
    # NB: hg log -r "(descendants(id(badddddd)) - descendants(id(baddddddd)))" happens to return the empty set, like we want"
    return '(descendants(id(' + firstBad + '))-descendants(id(' + firstGood + ')))'

def knownBrokenRangesBrowser(options):
    skips = [
        hgrange('cc45fdc389df', 'e8938a43c31a'), # Builds with --disable-crashreporter were broken (see bug 779291)
        hgrange('19f154ee6f54', 'd97ecf9f9b84'), # Backed out for bustage
        hgrange('eaa88688e9e8', '7a7e1ca619c2'), # Missing include (affected Jesse's MBP but not Tinderbox)
        hgrange('fbc1e196ca87', '7a9887e1f55e'), # Quick followup for bustage
        hgrange('bfef9b308f92', '991938589ebe'), # A landing required a build fix and a startup-assertion fix
        hgrange('b6dc96f18391', '37e29c27e6e8'), # Duplicate symbols with 10.9 SDK, between ICU being built by default and a bug being fixed
        hgrange('ad70d9583d42', 'd0f501b227fc'), # Short bustage
        hgrange('c5906eed61fc', '1c4ac1d21d29'), # Builds succeed but die early in startup
    ]

    return skips

def knownBrokenRanges(options):
    '''Returns a list of revsets corresponding to known-busted revisions'''
    # Paste numbers into: https://hg.mozilla.org/mozilla-central/rev/<number> to get hgweb link.
    # To add to the list:
    # - (1) will tell you when the brokenness started
    # - (1) autoBisect.py --compilationFailedLabel=bad -e FAILINGREV
    # - (2) will tell you when the brokenness ended
    # - (2) autoBisect.py --compilationFailedLabel=bad -s FAILINGREV

    # ANCIENT FIXME: It might make sense to avoid (or note) these in checkBlameParents.

    skips = [
        hgrange('d633e3ff2013', 'bcbe93f41547'), # Fx29, broken non-threadsafe
        hgrange('dbeea0e93b56', 'b980c2dee2e7'), # Fx29, broken non-threadsafe
        hgrange('995f7402235b', '6c899a1064f3'), # Fx30, broken non-threadsafe
        hgrange('d2c4ae312b66', 'abfaf0ccae19'), # Fx30, broken non-threadsafe
        hgrange('7cff27cb2845', 'ff5ca7959511'), # Fx30, broken build config w/ NSPR
        hgrange('07c0cf637290', 'f2adbe2a41c0'), # Fx31, broken non-threadsafe
        hgrange('99a6ee6466f5', '5c9119729bbf'), # Fx32, unstable spidermonkey
        hgrange('93dce4b831f3', '143ce643d1b3'), # Fx32, asserts when run with --thread-count=1
        hgrange('573458d10426', '5a50315d4d7d'), # Fx33, broken non-threadsafe
        hgrange('6b285759568c', 'e498b157651e'), # Fx34, broken ICU
        hgrange('03242a11d044', '31714af41f2c'), # Fx35, broken spidermonkey due to let changes
    ]

    if isARMv7l:
        skips.extend([
            hgrange('688d526f9313', '280aa953c868'), # Fx29-30, broken ARM builds
            hgrange('35e7af3e86fd', 'a393ec07bc6a'), # Fx32, broken ARM builds
        ])

    if isWin:
        skips.extend([
            hgrange('f6d5a48271b6', 'dc128b242d8a'), # Fx29, broken Windows builds due to ICU
            hgrange('17c463691232', 'f76b7bc18dbc'), # Fx29-30, build breakage
            hgrange('d959285c827e', 'edf5e2dc9198'), # Fx33, build breakage
        ])

    if isMozBuild64:
        skips.extend([
            hgrange('77d06ee9ac48', 'e7bb99d245e8'), # Fx28-29, breakage due to moz.build error
        ])

    if options.enableMoreDeterministic:
        skips.extend([
            hgrange('4a04ca5ed7d3', '406904577dfc'), # Fx33, see bug 1030014
            hgrange('752ce35b166b', 'e6e63113336d'), # Fx35, see bug 1069704
        ])

    return skips

def earliestKnownWorkingRevForBrowser(options):
    if isMac and macVer() >= [10, 9]:
        return '1c4ac1d21d29' # beacc621ec68 fixed 10.9 builds, but landed in the middle of unrelated bustage
    return '4e852ca66ea0' # or 'd97862fb8e6d' (same as js below) ... either way, oct 2012 on mac :(

def earliestKnownWorkingRev(options, flags, skipRevs):
    '''
    Returns a revset which evaluates to the first revision of the shell that
    compiles with |options| and runs jsfunfuzz successfully with |flags|.
    '''
    assert (not isMac) or (macVer() >= [10, 7])  # Only Lion and above are supported with Clang 4.

    # These should be in descending order, or bisection will break at earlier changesets.

    offthreadCompileFlag = asmNopFillFlag = asmPoolMaxOffsetFlag = False
    # flags is a list of flags, and the option must exactly match.
    for entry in flags:
        # What comes after these flags needs to be a number, so we look for the string instead.
        if '--ion-offthread-compile=' in entry:
            offthreadCompileFlag = True
        elif '--arm-asm-nop-fill=' in entry:
            asmNopFillFlag = True
        elif '--asm-pool-max-offset=' in entry:
            asmPoolMaxOffsetFlag = True

    required = []

    if '--no-threads' in flags:
        required.append('e8558ecd9b16') # m-c 195999 Fx34, 1st w/--no-threads, see bug 1031529
    if isWin64 or '--enable-nspr-build' in options.enableNsprBuild:  # Win64 has peculiar complexities prior to this
{'fraction_non_alphanumeric': 0.11066782307025151, 'fraction_numerical': 0.09765828274067649, 'mean_word_length': 3.3365927040240693, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4728823', 'n_tokens_mistral': 4691, 'n_tokens_neox': 4029, 'n_words': 1120}