How to use build_tests method in gabbi

Best Python code snippet using gabbi_python

cmakegen.py

Source:cmakegen.py Github

copy

Full Screen

1import argparse2import os3import platform4import sys5import subprocess6from abc import ABC, abstractmethod7def run_cmd(command):8 subprocess.run(command, shell=True)9def change_working_dir_to(path):10 os.chdir(path)11class IBuilder(ABC):12 '''13 Abstract class to generate a project for some IDEs.14 '''15 def __init__(self, generator, build_type, build_tests):16 self.build_dir = 'build'17 self.generator = generator18 self.build_type = build_type19 self.build_tests = build_tests20 @abstractmethod21 def create_build_dir(self):22 pass23 @abstractmethod24 def generate_project(self):25 pass26 def get_cmake_generate_command(self):27 return 'cmake -G "{}" .. -DCMAKE_BUILD_TYPE={} -DBUILD_TESTS={}'.format(28 self.generator, self.build_type, self.build_tests)29class XcodeBuilder(IBuilder):30 '''31 Class to generate a project for Xcode IDE.32 '''33 def __init__(self, build_type, build_tests):34 super().__init__('Xcode', build_type, build_tests)35 def create_build_dir(self):36 run_cmd('mkdir -p {}'.format(self.build_dir))37 change_working_dir_to(self.build_dir)38 def generate_project(self):39 run_cmd(super().get_cmake_generate_command())40class VisualStudioBuilder(IBuilder):41 '''42 Class to generate a project for Visual Studio IDE.43 '''44 def __init__(self, build_type, build_tests):45 super().__init__('Visual Studio 17 2022', build_type, build_tests)46 self.platform = 'x64'47 def create_build_dir(self):48 run_cmd('if not exist {0} mkdir {0} && pushd {0}'.format(self.build_dir))49 change_working_dir_to(self.build_dir)50 def generate_project(self):51 run_cmd('{} -A {}'.format(super().get_cmake_generate_command(), self.platform))52class UnixBuilder(IBuilder):53 '''54 Class to generate a project for QtCreator IDE.55 '''56 def __init__(self, build_type, build_tests):57 super().__init__('CodeBlocks - Unix Makefiles', build_type, build_tests)58 def create_build_dir(self):59 run_cmd('mkdir -p {}'.format(self.build_dir))60 change_working_dir_to(self.build_dir)61 def generate_project(self):62 run_cmd(super().get_cmake_generate_command())63def create_builder(build_type, build_tests):64 '''65 Factory method that makes a project builder for the specific platform.66 '''67 platform_name = platform.system()68 if platform_name == 'Darwin':69 return XcodeBuilder(build_type, build_tests)70 elif platform_name == 'Windows':71 return VisualStudioBuilder(build_type, build_tests)72 elif platform_name == 'Linux':73 return UnixBuilder(build_type, build_tests)74def main():75 parser = argparse.ArgumentParser()76 parser.add_argument('--build-type', '-b', dest='build_type', default='Debug')77 parser.add_argument('--build-tests', '-t', action='store_true')78 args = parser.parse_args()79 builder = create_builder(args.build_type, args.build_tests)80 builder.create_build_dir()81 builder.generate_project()82 return 083if __name__ == '__main__':...

Full Screen

Full Screen

conanfile.py

Source:conanfile.py Github

copy

Full Screen

1from conans import ConanFile, CMake, tools2class CPGenConan(ConanFile):3 name = "cpgen"4 version = "0.1"5 license = "BSD"6 author = "Benjamin Navarro <navarro.benjamin13@gmail.com>"7 url = "https://github.com/BenjaminNavarro/cpgen"8 description = "A C++ project generator based on CMake and Conan"9 topics = "C++", "Conan", "CMake"10 settings = "os", "compiler", "build_type", "arch"11 options = {"build_tests": [True, False]}12 default_options = {"build_tests": False}13 generators = "cmake"14 requires = "fmt/7.1.2", "cli11/1.9.1", "libcurl/7.73.0", "libarchive/3.4.3"15 exports_sources = "!.clangd*", "!.ccls-cache*", "!compile_commands.json", "*"16 def configure(self):17 self.options["libarchive"].with_acl = False18 def requirements(self):19 if self.options.build_tests:20 self.requires("cppcheck_installer/2.0@bincrafters/stable")21 self.requires("catch2/2.13.0")22 def build(self):23 cmake = CMake(self)24 if self.options.build_tests:25 cmake.definitions["ENABLE_TESTING"] = True26 cmake.configure()27 cmake.build()28 if self.options.build_tests:29 cmake.test()30 cmake.install()31 def package(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run gabbi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful