示例#1
0
def TestBuild(registry, out_dir):
    foo_path = os.path.join(SCRIPT_DIR, 'foo.txt')
    bar_path = os.path.join(SCRIPT_DIR, 'bar.txt')
    bottom_file = os.path.join(out_dir, 'bottom.txt')
    middle1_file = os.path.join(out_dir, 'middle1.txt')
    middle2_file = os.path.join(out_dir, 'middle2.txt')
    middle3_file = os.path.join(out_dir, 'middle3.txt')
    top_file = os.path.join(out_dir, 'top.txt')

    bottom = registry.SubRespire(GenerateBottom,
                                 out_dir=out_dir,
                                 out_file=bottom_file)
    middle1 = registry.SubRespire(CatBottomWith,
                                  out_dir=out_dir,
                                  bottom_file=bottom_file,
                                  cat_file=foo_path,
                                  out_file=middle1_file)
    middle2 = registry.SubRespire(CatBottomWith,
                                  out_dir=out_dir,
                                  bottom_file=bottom_file,
                                  cat_file=bar_path,
                                  out_file=middle2_file)
    middle3 = registry.SubRespire(CatFiles,
                                  out_dir=out_dir,
                                  inputs=[bottom, bottom],
                                  out_file=middle3_file)
    top = registry.SubRespire(CatFiles,
                              out_dir=out_dir,
                              inputs=[middle1, middle2, middle3],
                              out_file=top_file)

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'diamond.TestBuild.count'))
示例#2
0
def TestBuild(registry, out_dir):
    out_dir = out_dir
    bar_path = os.path.join(SCRIPT_DIR, 'bar.txt')
    base_chain_out_file_1 = os.path.join(out_dir, 'chain_output_1')
    base_chain_out_file_2 = os.path.join(out_dir, 'chain_output_2')
    chain_results_1_path = os.path.join(out_dir, 'chain_results_1.txt')
    chain_results_2_path = os.path.join(out_dir, 'chain_results_2.txt')

    chain_results1 = registry.SubRespire(Chain,
                                         input=bar_path,
                                         base_out_file=base_chain_out_file_1,
                                         number=3,
                                         out_dir=out_dir)

    chain_results2 = registry.SubRespire(Chain,
                                         input=bar_path,
                                         base_out_file=base_chain_out_file_2,
                                         number=4,
                                         out_dir=out_dir)

    registry.SubRespire(WriteResults,
                        results=chain_results1,
                        out_file=chain_results_1_path,
                        out_dir=out_dir)

    registry.SubRespire(WriteResults,
                        results=chain_results2,
                        out_file=chain_results_2_path,
                        out_dir=out_dir)

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'chain.TestBuild.count'))
示例#3
0
def TestBuild(registry, out_dir):
  foo_path = os.path.join(SCRIPT_DIR, 'foo.txt')
  bar_path = os.path.join(SCRIPT_DIR, 'bar.txt')
  foo_foo_path = os.path.join(out_dir, 'foofoo.txt')
  bar_bar_path = os.path.join(out_dir, 'barbar.txt')
  foo_bar_path = os.path.join(out_dir, 'foofoobarbar.txt')

  registry.SystemCommand(
      inputs=[foo_path],
      outputs=[foo_foo_path],
      command=utils.CatCommand([foo_path, foo_path], foo_foo_path))

  registry.SystemCommand(
      inputs=[bar_path],
      outputs=[bar_bar_path],
      command=utils.CatCommand([bar_path, bar_path], bar_bar_path,
                               os.path.join(out_dir, 'bar_bar.count')))

  registry.SystemCommand(
      inputs=[foo_foo_path, bar_bar_path],
      outputs=[foo_bar_path],
      command=utils.CatCommand([foo_foo_path, bar_bar_path], foo_bar_path))

  # Track how many times this python is executed.
  utils.AddCount(os.path.join(out_dir, 'single_function.count'))
示例#4
0
def CatFiles(registry, out_dir, inputs, output_file):
  utils.AddCount(os.path.join(out_dir, 'CatFiles.count'))
  registry.SystemCommand(
      inputs=inputs,
      outputs=[output_file],
      command=utils.CatCommand(inputs, output_file))
  return output_file
示例#5
0
def WriteAsString(registry, out_dir, contents, out_file):
    registry.SystemCommand(inputs=[],
                           outputs=[out_file],
                           command=utils.EchoCommand(str(contents), out_file))

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'WriteAsString.count'))
示例#6
0
def TestBuild(registry, out_dir):
    two_file = os.path.join(out_dir, 'two_file.txt')
    three_file = os.path.join(out_dir, 'three_file.txt')
    three_again_file = os.path.join(out_dir, 'three_again_file.txt')
    four_file = os.path.join(out_dir, 'four_file.txt')

    two = registry.SubRespire(AddNumbers, out_dir=out_dir, numbers=[1, 1])
    three = registry.SubRespire(AddNumbers, out_dir=out_dir, numbers=[1, two])
    three_again = registry.SubRespire(AddNumbers,
                                      out_dir=out_dir,
                                      numbers=[1, 2])
    four = registry.SubRespire(AddNumbers, out_dir=out_dir, numbers=[1, 3])

    registry.SubRespire(WriteAsString,
                        out_dir=out_dir,
                        out_file=two_file,
                        contents=two)
    registry.SubRespire(WriteAsString,
                        out_dir=out_dir,
                        out_file=three_file,
                        contents=three)
    registry.SubRespire(WriteAsString,
                        out_dir=out_dir,
                        out_file=three_again_file,
                        contents=three_again)
    registry.SubRespire(WriteAsString,
                        out_dir=out_dir,
                        out_file=four_file,
                        contents=four)

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'add_numbers.TestBuild.count'))
def TestBuild(registry, out_dir):
  stdin_path = os.path.join(out_dir, 'stdin.txt')
  stdout_path = os.path.join(out_dir, 'stdout.txt')
  stderr_path = os.path.join(out_dir, 'stderr.txt')
  final_path = os.path.join(out_dir, 'final.txt')

  registry.SystemCommand(
      inputs=[],
      outputs=[stdin_path],
      command=utils.EchoCommand('in', stdin_path))

  registry.SystemCommand(
      inputs=[],
      outputs=[],
      command=utils.EchoCommand('out', 'stdout'),
      stdout=stdout_path)

  registry.SystemCommand(
      inputs=[],
      outputs=[],
      command=utils.EchoCommand('err', 'stderr'),
      stderr=stderr_path)

  registry.SystemCommand(
      inputs=[stdout_path, stderr_path],
      outputs=[final_path],
      command=utils.CatCommand(
                  [stdout_path, stderr_path, 'stdin'], final_path,
                  os.path.join(out_dir, 'final.count')),
      stdin=stdin_path)

  # Track how many times this python is executed.
  utils.AddCount(os.path.join(out_dir, 'stdouterrin_function.count'))
示例#8
0
def GenerateBottom(registry, out_dir, out_file):
    registry.SystemCommand(inputs=[],
                           outputs=[out_file],
                           command=utils.EchoCommand('TheBottom', out_file))

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'GenerateBottom.count'))
    return out_file
示例#9
0
def WriteResults(registry, out_dir, results, out_file):
    registry.SystemCommand(inputs=[],
                           outputs=[out_file],
                           command=utils.EchoCommand(str(results[1][1][0][1]),
                                                     out_file))

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'WriteResults.count'))
def WriteObjectValueWithoutImport(registry, out_dir, a):
    out_file = os.path.join(out_dir, 'value_without_import.txt')

    utils.AddCount(
        os.path.join(out_dir, 'write_object_value_without_import.count'))

    registry.SystemCommand(inputs=[],
                           outputs=[out_file],
                           command=utils.EchoCommand(a.GetValue(), out_file))
示例#11
0
def AddNumbers(registry, out_dir, numbers):
    utils.AddCount(os.path.join(out_dir, 'AddNumbers.count'))
    if numbers[1] == 0:
        return numbers[0]
    else:
        return registry.SubRespire(AddOne,
                                   number=registry.SubRespire(
                                       AddNumbers,
                                       out_dir=out_dir,
                                       numbers=[numbers[0], numbers[1] - 1]))
示例#12
0
def CatBottomWith(registry, out_dir, bottom_file, cat_file, out_file):
    utils.AddCount(os.path.join(out_dir, 'CatBottomWith.count'))

    bottom = registry.SubRespire(GenerateBottom,
                                 out_dir=out_dir,
                                 out_file=bottom_file)

    return registry.SubRespire(CatFiles,
                               out_dir=out_dir,
                               inputs=[bottom, cat_file],
                               out_file=out_file)
示例#13
0
def TestBuild(registry, out_dir):
    foo_path = os.path.join(SCRIPT_DIR, 'foo.txt')
    foo_foo_path = os.path.join(out_dir, 'foofoo.txt')

    registry.SubRespire(DoubleInput,
                        input=foo_path,
                        output=foo_foo_path,
                        out_dir=out_dir)

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'double_input.TestBuild.count'))
示例#14
0
def GenerateBar(registry, out_dir):
  bar_filepath = os.path.join(out_dir, 'bar.txt')

  registry.SystemCommand(
      inputs=[],
      outputs=[bar_filepath],
      command=utils.EchoCommand('bar', bar_filepath))

  # Track how many times this python is executed.
  utils.AddCount(os.path.join(out_dir, 'GenerateBar.count'))
  return bar_filepath
def CatDirectory(inputs, outputs, out_dir):

    with open(outputs[0], 'w') as o:
        # Sort the inputs by their filenames so that we're guaranteed to be
        # deterministic about it.
        for entry in sorted(os.listdir(inputs[0])):
            with open(os.path.join(inputs[0], entry), 'r') as i:
                o.write(i.read())

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'cat_directory.count'))
示例#16
0
def GenerateFoo(registry, out_dir):
    foo_filepath = os.path.join(out_dir, 'foo.txt')

    registry.SystemCommand(inputs=[],
                           outputs=[foo_filepath],
                           command=utils.EchoCommand(get_foo_value.foo_value,
                                                     foo_filepath))

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'GenerateFoo.count'))
    return foo_filepath
示例#17
0
def TestBuild(registry, out_dir):
    input_file = os.path.join(out_dir, 'input_file.txt')
    output_file = os.path.join(out_dir, 'output_file.txt')

    registry.RegisterSelfDependency(input_file)

    with open(input_file, 'r') as f:
        input_contents = f.read()

    registry.PythonFunction(inputs=[],
                            outputs=[output_file],
                            function=WriteContent,
                            content=input_contents)

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'build_dynamic_dependency.count'))
示例#18
0
def TestBuild(registry, out_dir):
  bottom_file = os.path.join(out_dir, 'bottom.txt')
  out_file = os.path.join(out_dir, 'out.txt')

  bottom = registry.SubRespire(
      GenerateBottom, out_dir=out_dir, out_file=bottom_file)

  # Ultimately these should all result in the same output command.
  out_file_1 = registry.SubRespire(CatFiles,
      out_dir=out_dir, inputs=[bottom, bottom], output_file=out_file)
  out_file_2 = registry.SubRespire(CatFiles,
      out_dir=out_dir, inputs=[bottom_file, bottom], output_file=out_file)
  out_file_3 = registry.SubRespire(CatFiles,
      out_dir=out_dir, inputs=[bottom, bottom_file], output_file=out_file)

  # Track how many times this python is executed.
  utils.AddCount(os.path.join(out_dir, 'futures_resolve.TestBuild.count'))
def TestBuild(registry, out_dir):
    a = registry.SubRespireExternal('get_object_value.respire.py',
                                    'GetObjectValue',
                                    out_dir=out_dir)

    registry.SubRespireExternal('write_object_value_with_import.respire.py',
                                'WriteObjectValueWithImport',
                                out_dir=out_dir,
                                a=a)

    registry.SubRespireExternal('write_object_value_without_import.respire.py',
                                'WriteObjectValueWithoutImport',
                                out_dir=out_dir,
                                a=a)

    utils.AddCount(
        os.path.join(out_dir, 'can_pass_object_as_parameter.TestBuild.count'))
示例#20
0
def Chain(registry, out_dir, input, number, base_out_file):
    out_file = base_out_file + str(number) + '.txt'
    registry.SystemCommand(inputs=[input],
                           outputs=[out_file],
                           command=utils.CatCommand([input, input], out_file))
    return_value = [[out_file, number]]
    if number > 1:
        return_value.append(
            registry.SubRespire(Chain,
                                input=out_file,
                                base_out_file=base_out_file,
                                number=number - 1,
                                out_dir=out_dir))

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'Chain.count'))

    return return_value
示例#21
0
def TestBuild(registry, out_dir):
    foobar_filepath = os.path.join(out_dir, 'foobar.txt')

    foo = registry.SubRespireExternal('generate_foo.respire.py',
                                      'GenerateFoo',
                                      out_dir=out_dir)
    bar = registry.SubRespireExternal('generate_bar.respire.py',
                                      'GenerateBar',
                                      out_dir=out_dir)

    registry.SubRespireExternal('cat_files.respire.py',
                                'CatFiles',
                                inputs=[foo, bar],
                                output_file=foobar_filepath,
                                out_dir=out_dir)

    # Track how many times this python is executed.
    utils.AddCount(
        os.path.join(out_dir, 'simple_test_entry_point.TestBuild.count'))
示例#22
0
def TestBuild(registry, out_dir):
    foo_path = os.path.join(SCRIPT_DIR, 'foo.txt')
    bar_path = os.path.join(SCRIPT_DIR, 'bar.txt')
    foo_foo_path = os.path.join(out_dir, 'foofoo.txt')
    bar_bar_path = os.path.join(out_dir, 'barbar.txt')
    foo_bar_path = os.path.join(out_dir, 'foofoobarbar.txt')

    registry.SystemCommand(inputs=[foo_path],
                           outputs=[foo_foo_path],
                           command=utils.CatCommand([foo_path, foo_path],
                                                    foo_foo_path))

    registry.PythonFunction(inputs=[bar_path],
                            outputs=[bar_bar_path],
                            function=_DoubleFile,
                            my_input=bar_path,
                            my_output=bar_bar_path)

    registry.PythonFunction(inputs=[foo_foo_path, bar_bar_path],
                            outputs=[foo_bar_path],
                            function=_ConcatenateFiles)

    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'python_function.count'))
示例#23
0
def DoubleInput(registry, out_dir, input, output):
    registry.SystemCommand(inputs=[input],
                           outputs=[output],
                           command=utils.CatCommand([input, input], output))
    # Track how many times this python is executed.
    utils.AddCount(os.path.join(out_dir, 'DoubleInput.count'))
示例#24
0
def GetObjectValue(registry, out_dir):
    utils.AddCount(os.path.join(out_dir, 'get_object_value.count'))

    return foo_class.Foo('woof', 'bark')