Beispiel #1
0
 def testMultiWorkload(self) -> None:
     worker = bzd.utils.worker.Worker(TestWorker.foo)
     for i in range(100):
         worker.add(i)
     self.assertEqual(worker.shared["count"].value, 100)
     worker.start()
     result = list(worker.data())
     worker.stop()
     self.assertEqual(len(result), 100)
Beispiel #2
0
 def testSingleWorkload(self) -> None:
     worker = bzd.utils.worker.Worker(TestWorker.foo)
     worker.start()
     worker.add(12)
     result = list(worker.data())
     worker.stop()
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].isSuccess(), True)
     self.assertEqual(result[0].getResult(), 12 * 12)
     self.assertEqual(result[0].getOutput(), "Hello")
Beispiel #3
0
def evaluateFiles(task: Callable[[str, TextIO], Any], workspace: Path,
                  **kwargs: Any) -> bool:
    files = Files(workspace, useGitignore=True, **kwargs)
    worker = bzd.utils.worker.Worker(task)
    worker.start()
    for path in files.data():
        worker.add(path.as_posix())

    isSuccess = True
    for result in worker.data():
        if not result.isSuccess():
            isSuccess = False
            print(result.getOutput(), end="")

    worker.stop()

    return isSuccess
Beispiel #4
0
    parser = argparse.ArgumentParser(description="Wrapper for mypy")
    parser.add_argument("workspace",
                        type=Path,
                        help="Workspace to be processed.")

    args = parser.parse_args()

    files = Files(args.workspace,
                  include=[
                      "**/*.py",
                  ],
                  exclude=[
                      "**tools/bzd/generator/yaml**",
                  ])

    # Process the varous files
    worker = bzd.utils.worker.Worker(yapfWorker)
    worker.start()
    for path in files.data():
        worker.add(path.as_posix())

    isSuccess = True
    for result in worker.data():
        if not result.isSuccess():
            isSuccess = False
            print(result.getOutput(), end="")

    worker.stop()

    sys.exit(0 if isSuccess else 1)
Beispiel #5
0
 def Empty(self) -> None:
     worker = bzd.utils.worker.Worker(TestWorker.foo)
     worker.start()
     result = list(worker.data())
     worker.stop()
     self.assertEqual(len(result), 0)