Beispiel #1
0
def create(app, ref, graph_info, remotes, update, build_modes,
           manifest_folder, manifest_verify, manifest_interactive, keep_build, test_build_folder,
           test_folder, conanfile_path, recorder):
    assert isinstance(ref, ConanFileReference), "ref needed"
    test_conanfile_path = _get_test_conanfile_path(test_folder, conanfile_path)

    if test_conanfile_path:
        install_build_and_test(app, test_conanfile_path, ref, graph_info, remotes, update,
                               build_modes=build_modes,
                               manifest_folder=manifest_folder,
                               manifest_verify=manifest_verify,
                               manifest_interactive=manifest_interactive,
                               keep_build=keep_build,
                               test_build_folder=test_build_folder,
                               recorder=recorder)
    else:
        deps_install(app=app,
                     ref_or_path=ref,
                     create_reference=ref,
                     install_folder=None,  # Not output anything
                     manifest_folder=manifest_folder,
                     manifest_verify=manifest_verify,
                     manifest_interactive=manifest_interactive,
                     remotes=remotes,
                     graph_info=graph_info,
                     build_modes=build_modes,
                     update=update,
                     keep_build=keep_build,
                     recorder=recorder)
Beispiel #2
0
def install_build_and_test(app, conanfile_abs_path, reference, graph_info,
                           remotes, update, build_modes=None, manifest_folder=None,
                           manifest_verify=False, manifest_interactive=False, keep_build=False,
                           test_build_folder=None, recorder=None):
    """
    Installs the reference (specified by the parameters or extracted from the test conanfile)
    and builds the test_package/conanfile.py running the test() method.
    """
    base_folder = os.path.dirname(conanfile_abs_path)
    test_build_folder, delete_after_build = _build_folder(test_build_folder, graph_info.profile_host,
                                                          base_folder)
    rmdir(test_build_folder)
    if build_modes is None:
        build_modes = ["never"]
    try:
        deps_install(app=app,
                     create_reference=reference,
                     ref_or_path=conanfile_abs_path,
                     install_folder=test_build_folder,
                     remotes=remotes,
                     graph_info=graph_info,
                     update=update,
                     build_modes=build_modes,
                     manifest_folder=manifest_folder,
                     manifest_verify=manifest_verify,
                     manifest_interactive=manifest_interactive,
                     keep_build=keep_build,
                     recorder=recorder)
        cmd_build(app, conanfile_abs_path, base_folder, test_build_folder, package_folder=None,
                  install_folder=test_build_folder, test=reference)
    finally:
        if delete_after_build:
            # Required for windows where deleting the cwd is not possible.
            os.chdir(base_folder)
            rmdir(test_build_folder)
Beispiel #3
0
def create(app, ref, graph_info, remotes, update, build_modes,
           manifest_folder, manifest_verify, manifest_interactive, keep_build, test_build_folder,
           test_folder, conanfile_path, recorder, is_build_require=False, require_overrides=None):
    assert isinstance(ref, ConanFileReference), "ref needed"
    test_conanfile_path = _get_test_conanfile_path(test_folder, conanfile_path)

    if test_conanfile_path:
        if graph_info.graph_lock:
            # If we have a lockfile, then we are first going to make sure the lockfile is used
            # correctly to build the package in the cache, and only later will try to run
            # test_package
            out = app.out
            out.info("Installing and building %s" % repr(ref))
            deps_install(app=app,
                         ref_or_path=ref,
                         create_reference=ref,
                         install_folder=None,  # Not output conaninfo etc
                         base_folder=None,  # Not output generators
                         manifest_folder=manifest_folder,
                         manifest_verify=manifest_verify,
                         manifest_interactive=manifest_interactive,
                         remotes=remotes,
                         graph_info=graph_info,
                         build_modes=build_modes,
                         update=update,
                         keep_build=keep_build,
                         recorder=recorder,
                         conanfile_path=os.path.dirname(test_conanfile_path))
            out.info("Executing test_package %s" % repr(ref))
            try:
                graph_info.graph_lock.relax()
                # FIXME: It needs to clear the cache, otherwise it fails
                app.binaries_analyzer._evaluated = {}
                # FIXME: Forcing now not building test dependencies, binaries should be there
                install_build_and_test(app, test_conanfile_path, ref, graph_info, remotes,
                                       update, build_modes=None,
                                       test_build_folder=test_build_folder, recorder=recorder)
            except Exception as e:
                raise ConanException("Something failed while testing '%s' test_package after "
                                     "it was built using the lockfile. Please report this error: %s"
                                     % (str(ref), str(e)))

        else:
            install_build_and_test(app, test_conanfile_path,
                                   ref, graph_info, remotes, update,
                                   build_modes=build_modes,
                                   manifest_folder=manifest_folder,
                                   manifest_verify=manifest_verify,
                                   manifest_interactive=manifest_interactive,
                                   keep_build=keep_build,
                                   test_build_folder=test_build_folder,
                                   recorder=recorder,
                                   require_overrides=require_overrides
                                   )
    else:
        deps_install(app=app,
                     ref_or_path=ref,
                     create_reference=ref,
                     install_folder=None,  # Not output infos etc
                     base_folder=None,  # Not output generators
                     manifest_folder=manifest_folder,
                     manifest_verify=manifest_verify,
                     manifest_interactive=manifest_interactive,
                     remotes=remotes,
                     graph_info=graph_info,
                     build_modes=build_modes,
                     update=update,
                     keep_build=keep_build,
                     recorder=recorder,
                     is_build_require=is_build_require,
                     require_overrides=require_overrides)
Beispiel #4
0
def install_build_and_test(app,
                           conanfile_abs_path,
                           reference,
                           graph_info,
                           remotes,
                           update,
                           build_modes=None,
                           manifest_folder=None,
                           manifest_verify=False,
                           manifest_interactive=False,
                           keep_build=False,
                           test_build_folder=None,
                           recorder=None,
                           require_overrides=None):
    """
    Installs the reference (specified by the parameters or extracted from the test conanfile)
    and builds the test_package/conanfile.py running the test() method.
    """
    base_folder = os.path.dirname(conanfile_abs_path)

    # FIXME: Remove this check in 2.0, always use the base_folder
    conanfile = app.loader.load_basic(conanfile_abs_path)
    if hasattr(conanfile, "layout"):
        # Don't use "test_package/build/HASH/" as the build_f
        delete_after_build = False
        test_build_folder = base_folder
    else:
        test_build_folder, delete_after_build = _build_folder(
            test_build_folder, graph_info.profile_host, base_folder)
        rmdir(test_build_folder)
    if build_modes is None:
        build_modes = ["never"]
    try:
        deps_install(
            app=app,
            create_reference=reference,
            ref_or_path=conanfile_abs_path,
            install_folder=test_build_folder,
            base_folder=test_build_folder,
            remotes=remotes,
            graph_info=graph_info,
            update=update,
            build_modes=build_modes,
            manifest_folder=manifest_folder,
            manifest_verify=manifest_verify,
            manifest_interactive=manifest_interactive,
            keep_build=keep_build,
            recorder=recorder,
            require_overrides=require_overrides,
            conanfile_path=os.path.dirname(conanfile_abs_path),
            test=True  # To keep legacy test_package_layout
        )
        cmd_build(app,
                  conanfile_abs_path,
                  test_build_folder,
                  source_folder=base_folder,
                  build_folder=test_build_folder,
                  package_folder=os.path.join(test_build_folder, "package"),
                  install_folder=test_build_folder,
                  test=reference)
    finally:
        if delete_after_build:
            # Required for windows where deleting the cwd is not possible.
            os.chdir(base_folder)
            rmdir(test_build_folder)