forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test_fixtures GN rule that allows unittests to reference fixtur…
…es. (flutter#4280)
- Loading branch information
1 parent
6665645
commit 2d9f6ac
Showing
5 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2017 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import argparse | ||
import subprocess | ||
import sys | ||
import os | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description='Create the symbol specifying the location of test fixtures.') | ||
|
||
parser.add_argument('--fixtures_location_file', type=str, required=True) | ||
parser.add_argument('--fixtures_location', type=str, required=True) | ||
|
||
args = parser.parse_args() | ||
|
||
with open(args.fixtures_location_file, 'w') as file: | ||
file.write('namespace testing {const char* GetFixturesPath() {return "%s";}}' | ||
% args.fixtures_location) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2017 The Fuchsia Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "testing.h" | ||
|
||
namespace testing { | ||
|
||
// | ||
|
||
} // namespace testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2016 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
template("test_fixtures") { | ||
testonly = true | ||
|
||
assert(defined(invoker.fixtures), "Test fixtures must be specified.") | ||
|
||
fixtures_name_target_name = target_name + "_gen_fixtures_name" | ||
fixtures_source_set_target_name = target_name + "_gen_fixtures_source_set" | ||
fixtures_copy_target_name = target_name + "_copy_fixtures" | ||
|
||
fixtures_location = "$target_gen_dir/fixtures" | ||
fixtures_location_file = "$target_gen_dir/test_fixtures_location.cc" | ||
|
||
action(fixtures_name_target_name) { | ||
script = "$flutter_root/testing/build/gen_fixtures_location_symbol.py" | ||
|
||
outputs = [ | ||
fixtures_location_file, | ||
] | ||
|
||
args = [ | ||
"--fixtures_location_file", | ||
rebase_path(fixtures_location_file), | ||
"--fixtures_location", | ||
rebase_path(fixtures_location), | ||
] | ||
} | ||
|
||
source_set(fixtures_source_set_target_name) { | ||
sources = [ | ||
fixtures_location_file, | ||
] | ||
|
||
deps = [ | ||
":$fixtures_name_target_name", | ||
] | ||
} | ||
|
||
copy(fixtures_copy_target_name) { | ||
sources = invoker.fixtures | ||
outputs = [ | ||
"$fixtures_location/{{source_file_part}}", | ||
] | ||
} | ||
|
||
group(target_name) { | ||
deps = [ | ||
":$fixtures_copy_target_name", | ||
":$fixtures_source_set_target_name", | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2017 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef TESTING_TESTING_H_ | ||
#define TESTING_TESTING_H_ | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace testing { | ||
|
||
// Returns the directory containing the test fixture for the target if this | ||
// target has fixtures configured. If there are no fixtures, this is a link | ||
// error. | ||
const char* GetFixturesPath(); | ||
|
||
} // namespace testing | ||
|
||
#endif // TESTING_TESTING_H_ |