Repository: jerryscript-project/jerryscript
File: tools/run-tests.py (Python)

Code before:
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import collections
import hashlib
import os
import platform
import subprocess
import sys
import settings

from runners import util
from runners.util import TERM_NORMAL, TERM_YELLOW, TERM_BLUE, TERM_RED

OUTPUT_DIR = os.path.join(settings.PROJECT_DIR, 'build', 'tests')

# The saved result of get_arguments() for globally access
options = None # pylint: disable=invalid-name

Options = collections.namedtuple('Options', ['name', 'build_args', 'test_args', 'skip'])
Options.__new__.__defaults__ = ([], [], False)

def skip_if(condition, desc):
    return desc if condition else False

OPTIONS_COMMON = ['--lto=off', '--function-to-string=on']
OPTIONS_PROFILE_MIN = ['--profile=minimal']
OPTIONS_STACK_LIMIT = ['--stack-limit=96']
OPTIONS_GC_MARK_LIMIT = ['--gc-mark-limit=16']
OPTIONS_MEM_STRESS = ['--mem-stress-test=on']
OPTIONS_DEBUG = ['--debug']
OPTIONS_SNAPSHOT = ['--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on']
OPTIONS_UNITTESTS = ['--unittests=on', '--jerry-cmdline=off', '--error-messages=on',
                     '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on',
                     '--vm-throw=on', '--line-info=on', '--mem-stats=on', '--promise-callback=on']
OPTIONS_DOCTESTS = ['--doctests=on', '--jerry-cmdline=off', '--error-messages=on',
                    '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on']
OPTIONS_PROMISE_CALLBACK = ['--promise-callback=on']

# Test options for unittests
JERRY_UNITTESTS_OPTIONS = [
    Options('doctests',
            OPTIONS_COMMON + OPTIONS_DOCTESTS + OPTIONS_PROMISE_CALLBACK),

Review comment (suggestion):
This is a valid pylint warning, please don't suppress it. Give this a proper name instead. I am also not sure if we really need to make this whole object global.

Why don't we just do this instead?
```
def iterate_test_runner_jobs(jobs, timeout=None):
```

Code after:
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import collections
import hashlib
import os
import platform
import subprocess
import sys
import settings

from runners import util
from runners.util import TERM_NORMAL, TERM_YELLOW, TERM_BLUE, TERM_RED

OUTPUT_DIR = os.path.join(settings.PROJECT_DIR, 'build', 'tests')

Options = collections.namedtuple('Options', ['name', 'build_args', 'test_args', 'skip'])
Options.__new__.__defaults__ = ([], [], False)

def skip_if(condition, desc):
    return desc if condition else False

OPTIONS_COMMON = ['--lto=off', '--function-to-string=on']
OPTIONS_PROFILE_MIN = ['--profile=minimal']
OPTIONS_STACK_LIMIT = ['--stack-limit=96']
OPTIONS_GC_MARK_LIMIT = ['--gc-mark-limit=16']
OPTIONS_MEM_STRESS = ['--mem-stress-test=on']
OPTIONS_DEBUG = ['--debug']
OPTIONS_SNAPSHOT = ['--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on']
OPTIONS_UNITTESTS = ['--unittests=on', '--jerry-cmdline=off', '--error-messages=on',
                     '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on',
                     '--vm-throw=on', '--line-info=on', '--mem-stats=on', '--promise-callback=on']
OPTIONS_DOCTESTS = ['--doctests=on', '--jerry-cmdline=off', '--error-messages=on',
                    '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on']
OPTIONS_PROMISE_CALLBACK = ['--promise-callback=on']

# Test options for unittests
JERRY_UNITTESTS_OPTIONS = [
    Options('doctests',
            OPTIONS_COMMON + OPTIONS_DOCTESTS + OPTIONS_PROMISE_CALLBACK),
    Options('unittests',
            OPTIONS_COMMON + OPTIONS_UNITTESTS),
    Options('unittests-init-fini',