mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 01:07:01 +08:00
Check Ninja output with expected build output
We now check that the build_output.txt is equivalent to the build_output.txt.expected. This includes compilation failures, which `compilation_failure_front_end` shows. To be able to have machine-agnostic buildoutputs, the toolchains need to be absolutely referenced and thus every fixture needs the same copy of a toolchain. Also, the ts_library print must use the relative path rather than the absolute path. R=jacktfranklin@chromium.org DISABLE_THIRD_PARTY_CHECK=Add ts_library tests. Bug: 1064287 Change-Id: I4a4db566cc155b7f6e73cadc2efcfa8d615286ed Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2118097 Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
bd22e62bdc
commit
2ffbc3f6d5
+2
-1
@@ -45,6 +45,7 @@
|
||||
"start": "node scripts/hosted_mode/start_chrome_and_server.js",
|
||||
"test": "node scripts/npm_test.js",
|
||||
"test-local": "node scripts/npm_test.js --layout-tests-directory=test/webtests/",
|
||||
"unittest": "NO_TEXT_COVERAGE=1 python scripts/test/run_unittests.py"
|
||||
"unittest": "NO_TEXT_COVERAGE=1 python scripts/test/run_unittests.py",
|
||||
"ts_library-test": "./third_party/typescript/tests/verify_ts_libary.sh"
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
out/
|
||||
out/
|
||||
build_output.txt
|
||||
+1
-2
@@ -7,5 +7,4 @@ All tests are fixtures in the [fixtures/](fixtures/) directory, which are compil
|
||||
Each test fixture contains the following:
|
||||
- A `.gn` file which specifies this is a GN root, to run `gn gen` on the correct directory.
|
||||
- A `BUILDCONFIG.gn` which includes the minimal Chromium configuration to work with `autoninja`.
|
||||
|
||||
All fixtures specify the (otherwise unused) toolchain defined in `toolchain/BUILD.gn`, as it is required by Ninja to succesfully run a build.
|
||||
- A `toolchain/BUILD.gn` which specifies an (otherwise unused) toolchain, as it is required by Ninja to succesfully run a build.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Copyright 2020 the V8 project authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
buildconfig = "//BUILDCONFIG.gn"
|
||||
@@ -0,0 +1,7 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
group("compilation_failure_front_end") {
|
||||
deps = [ "front_end/module" ]
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2019 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.
|
||||
|
||||
declare_args() {
|
||||
devtools_location = "../../../../../"
|
||||
}
|
||||
|
||||
set_default_toolchain("//toolchain:default")
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
ninja: Entering directory `./third_party/typescript/tests/out/fixtures/compilation_failure_front_end'
|
||||
[1/5] ACTION //front_end/module:dep(//toolchain:default)
|
||||
[2/5] STAMP obj/front_end/module/dep.stamp
|
||||
[3/5] ACTION //front_end/module:module(//toolchain:default)
|
||||
FAILED: gen/front_end/module/module-tsconfig.json gen/front_end/module/module-tsconfig.json.tsbuildinfo gen/front_end/module/index.js gen/front_end/module/index.js.map resources/inspector/module/index.js gen/front_end/module/index.d.ts
|
||||
python ts_library.py --tsconfig_output_location gen/front_end/module/module-tsconfig.json --deps ./dep-tsconfig.json --front_end_directory ../../../fixtures/compilation_failure_front_end/front_end/module --sources ../../../fixtures/compilation_failure_front_end/front_end/module/index.ts
|
||||
|
||||
TypeScript compilation failed. Used tsconfig gen/front_end/module/module-tsconfig.json
|
||||
|
||||
../../../fixtures/compilation_failure_front_end/front_end/module/index.ts(3,1): error TS2349: This expression is not callable.
|
||||
Type 'Number' has no call signatures.
|
||||
|
||||
|
||||
ninja: build stopped: subcommand failed.
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
# Copyright 2020 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("../../../../../typescript.gni")
|
||||
|
||||
ts_library("module") {
|
||||
sources = [ "index.ts" ]
|
||||
|
||||
deps = [ ":dep" ]
|
||||
}
|
||||
|
||||
ts_library("dep") {
|
||||
sources = [ "exporting.ts" ]
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export const foo = 42;
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import {foo} from './exporting.js';
|
||||
|
||||
foo();
|
||||
-7
@@ -2,10 +2,6 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
pool("action_pool") {
|
||||
depth = 1
|
||||
}
|
||||
|
||||
toolchain("default") {
|
||||
# These two are really entirely generic, but have to be repeated in
|
||||
# each toolchain because GN doesn't allow a template to be used here.
|
||||
@@ -14,7 +10,4 @@ toolchain("default") {
|
||||
command = "touch {{output}}"
|
||||
description = "STAMP {{output}}"
|
||||
}
|
||||
tool("action") {
|
||||
pool = ":action_pool($default_toolchain)"
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,4 @@ declare_args() {
|
||||
devtools_location = "../../../../../"
|
||||
}
|
||||
|
||||
set_default_toolchain("../../toolchain:default")
|
||||
set_default_toolchain("//toolchain:default")
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
ninja: Entering directory `./third_party/typescript/tests/out/fixtures/simple_dep'
|
||||
[1/5] ACTION //front_end/module:dep(//toolchain:default)
|
||||
[2/5] STAMP obj/front_end/module/dep.stamp
|
||||
[3/5] ACTION //front_end/module:module(//toolchain:default)
|
||||
[4/5] STAMP obj/front_end/module/module.stamp
|
||||
[5/5] STAMP obj/simple_dep.stamp
|
||||
@@ -0,0 +1,13 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
toolchain("default") {
|
||||
# These two are really entirely generic, but have to be repeated in
|
||||
# each toolchain because GN doesn't allow a template to be used here.
|
||||
# See //build/toolchain/toolchain.gni for details.
|
||||
tool("stamp") {
|
||||
command = "touch {{output}}"
|
||||
description = "STAMP {{output}}"
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,4 @@ declare_args() {
|
||||
devtools_location = "../../../../../"
|
||||
}
|
||||
|
||||
set_default_toolchain("../../toolchain:default")
|
||||
set_default_toolchain("//toolchain:default")
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
ninja: Entering directory `./third_party/typescript/tests/out/fixtures/test_dep'
|
||||
[1/7] ACTION //front_end/module:dep(//toolchain:default)
|
||||
[2/7] STAMP obj/front_end/module/dep.stamp
|
||||
[3/7] ACTION //front_end/module:module(//toolchain:default)
|
||||
[4/7] STAMP obj/front_end/module/module.stamp
|
||||
[5/7] ACTION //test/module:module(//toolchain:default)
|
||||
[6/7] STAMP obj/test/module/module.stamp
|
||||
[7/7] STAMP obj/test_dep.stamp
|
||||
@@ -0,0 +1,13 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
toolchain("default") {
|
||||
# These two are really entirely generic, but have to be repeated in
|
||||
# each toolchain because GN doesn't allow a template to be used here.
|
||||
# See //build/toolchain/toolchain.gni for details.
|
||||
tool("stamp") {
|
||||
command = "touch {{output}}"
|
||||
description = "STAMP {{output}}"
|
||||
}
|
||||
}
|
||||
+27
-4
@@ -3,12 +3,35 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
ROOT_DIRECTORY=$(dirname "$0")
|
||||
TS_LIBRARY_PATH=$(realpath $ROOT_DIRECTORY/../ts_library.py | sed 's/\//\\\//g')
|
||||
|
||||
rm -rf $ROOT_DIRECTORY/out/fixtures
|
||||
failed=0
|
||||
|
||||
gn gen --root=$ROOT_DIRECTORY/fixtures/simple_dep $ROOT_DIRECTORY/out/fixtures/simple_dep
|
||||
autoninja -C $ROOT_DIRECTORY/out/fixtures/simple_dep simple_dep
|
||||
run_fixture() {
|
||||
local fixture_name="$1"
|
||||
local build_output_file="$ROOT_DIRECTORY/fixtures/$fixture_name/build_output.txt"
|
||||
|
||||
echo "Generating Ninja build files for $fixture_name"
|
||||
gn gen --root=$ROOT_DIRECTORY/fixtures/$fixture_name $ROOT_DIRECTORY/out/fixtures/$fixture_name
|
||||
|
||||
gn gen --root=$ROOT_DIRECTORY/fixtures/test_dep $ROOT_DIRECTORY/out/fixtures/test_dep
|
||||
autoninja -C $ROOT_DIRECTORY/out/fixtures/test_dep test_dep
|
||||
echo "Compiling with Ninja for $fixture_name"
|
||||
autoninja -C $ROOT_DIRECTORY/out/fixtures/$fixture_name $fixture_name > "$build_output_file"
|
||||
|
||||
# Replace the absolute python library path to make sure we can diff on different machines
|
||||
sed -i "" "s/$TS_LIBRARY_PATH/ts_library.py/g" $build_output_file
|
||||
|
||||
diff_output=$(diff "$build_output_file.expected" "$build_output_file")
|
||||
|
||||
if [[ "$diff_output" != "" ]]; then
|
||||
echo "Diff output for $fixture_name:"
|
||||
echo "$diff_output"
|
||||
failed=1
|
||||
fi
|
||||
}
|
||||
|
||||
run_fixture "simple_dep"
|
||||
run_fixture "test_dep"
|
||||
run_fixture "compilation_failure_front_end"
|
||||
|
||||
exit $failed
|
||||
Vendored
+1
-1
@@ -96,7 +96,7 @@ def main():
|
||||
found_errors, stderr = runTsc(tsconfig_location=tsconfig_output_location)
|
||||
if found_errors:
|
||||
print('')
|
||||
print('TypeScript compilation failed. Used tsconfig %s' % tsconfig_output_location)
|
||||
print('TypeScript compilation failed. Used tsconfig %s' % opts.tsconfig_output_location)
|
||||
print('')
|
||||
print(stderr)
|
||||
print('')
|
||||
|
||||
Reference in New Issue
Block a user