Changeset ef56087


Ignore:
Timestamp:
Mar 7, 2022, 7:38:52 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
5baa33c
Parents:
fc01219
Message:

Fixed test.py to support -j.
(unlimited jobs)

Location:
tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/pybin/tools.py

    rfc01219 ref56087  
    322322        # tell make about the pipes
    323323        os.environ["MAKEFLAGS"] = os.environ["MFLAGS"] = " ".join(make_flags)
    324         print(os.environ["MFLAGS"])
    325324
    326325        # make sure pass the pipes to our children
     
    328327
    329328        return make_flags
     329
     330def prep_unlimited_recursive_make():
     331        # prep the flags for make
     332        make_flags = ["-j"]
     333
     334        # tell make about the pipes
     335        os.environ["MAKEFLAGS"] = os.environ["MFLAGS"] = "-j"
     336
     337        return make_flags
     338
     339
     340def eval_hardware():
     341        # we can create as many things as we want
     342        # how much hardware do we have?
     343        if settings.distribute:
     344                # remote hardware is allowed
     345                # how much do we have?
     346                ret, jstr = sh("distcc", "-j", output_file=subprocess.PIPE, ignore_dry_run=True)
     347                return int(jstr.strip()) if ret == 0 else multiprocessing.cpu_count()
     348        else:
     349                # remote isn't allowed, use local cpus
     350                return multiprocessing.cpu_count()
    330351
    331352# count number of jobs to create
     
    375396                                sys.exit(1)
    376397
    377                         # we can create as many things as we want
    378                         # how much hardware do we have?
    379                         if settings.distribute:
    380                                 # remote hardware is allowed
    381                                 # how much do we have?
    382                                 ret, jstr = sh("distcc", "-j", output_file=subprocess.PIPE, ignore_dry_run=True)
    383                                 options.jobs = int(jstr.strip()) if ret == 0 else multiprocessing.cpu_count()
    384                         else:
    385                                 # remote isn't allowed, use local cpus
    386                                 options.jobs = multiprocessing.cpu_count()
    387 
    388                         make_flags = prep_recursive_make(options.jobs)
     398                        options.jobs = eval_hardware()
     399                        flags = prep_unlimited_recursive_make()
    389400
    390401
     
    397408
    398409        # Arguments are calling the shots, fake the top level make
    399         elif options.jobs:
     410        elif options.jobs :
     411
    400412                # make sure we have a valid number of jobs that corresponds to user input
    401                 if options.jobs <= 0 :
     413                if options.jobs < 0 :
    402414                        print('ERROR: Invalid number of jobs', file=sys.stderr)
    403415                        sys.exit(1)
    404416
    405417                flags = prep_recursive_make(options.jobs)
     418
     419        # Arguments are calling the shots, fake the top level make, but 0 is a special case
     420        elif options.jobs == 0:
     421                options.jobs = eval_hardware()
     422                flags = prep_unlimited_recursive_make()
    406423
    407424        # No one says to run in parallel, then don't
     
    412429        # Make sure we call make as expected
    413430        settings.update_make_cmd( flags )
     431        print(flags)
     432        print(os.environ.get('MAKEFLAGS'))
    414433
    415434        # return the job count
  • tests/test.py

    rfc01219 ref56087  
    140140        parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
    141141        parser.add_argument('--archive-errors', help='If called with a valid path, on test crashes the test script will copy the core dump and the executable to the specified path.', type=str, default='')
    142         parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously', type=int)
     142        parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously, 0 (default) for unlimited', nargs='?', const=0, type=int)
    143143        parser.add_argument('--list-comp', help='List all valide arguments', action='store_true')
    144144        parser.add_argument('--list-dist', help='List all tests for distribution', action='store_true')
Note: See TracChangeset for help on using the changeset viewer.