def main()

in tools/tftest_plan_summary.py [0:0]


def main(test_file, test_name):
  test_base_dir = Path(test_file).parent
  try:
    with open(test_file) as f:
      raw = yaml.safe_load(f)
    module = raw.pop('module')
  except (IOError, OSError, yaml.YAMLError) as e:
    raise Exception(f'cannot read test spec {test_file}: {e}')
  except KeyError as e:
    raise Exception(f'`module` key not found in {test_file}: {e}')

  common = raw.pop('common_tfvars', [])
  spec = raw.get('tests', {})[test_name] or {}
  extra_dirs = spec.get('extra_dirs', [])
  extra_files = spec.get('extra_files', [])
  tf_var_files = common + [f'{test_name}.tfvars'] + spec.get('tfvars', [])
  module_path = BASEDIR / module
  summary = fixtures.plan_summary(module_path, test_base_dir, tf_var_files,
                                  extra_files=extra_files,
                                  extra_dirs=extra_dirs)

  print(yaml.dump({'values': summary.values}))
  print(yaml.dump({'counts': summary.counts}))
  outputs = {
      k: v.get('value', '__missing__') for k, v in summary.outputs.items()
  }
  print(yaml.dump({'outputs': outputs}))