Fixup validator tests added during split from resolver.

This PR adds the validator_is_storable test into the CMakeList file
correctly and removes the helper files. The resolver helper is used
instead and a test helper to return the validator added into the
resolver.

Change-Id: I5b18bcc6373e3b39807af05cf5c058fab61ed4ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88041
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2022-04-26 22:19:22 +00:00 committed by Dawn LUCI CQ
parent 8e2a1f9ab9
commit d3a5080c7b
7 changed files with 10 additions and 75 deletions

View File

@ -772,6 +772,7 @@ if(TINT_BUILD_TESTS)
resolver/type_constructor_validation_test.cc
resolver/type_validation_test.cc
resolver/validation_test.cc
resolver/validator_is_storeable_test.cc
resolver/var_let_test.cc
resolver/var_let_validation_test.cc
scope_stack_test.cc

View File

@ -108,6 +108,9 @@ class Resolver {
return validator_.IsHostShareable(type);
}
/// @returns the validator for testing
const Validator* GetValidatorForTesting() const { return &validator_; }
private:
/// Describes the context in which a variable is declared
enum class VariableKind { kParameter, kLocal, kGlobal };

View File

@ -40,6 +40,9 @@ class TestHelper : public ProgramBuilder {
/// @return a pointer to the Resolver
Resolver* r() const { return resolver_.get(); }
/// @return a pointer to the validator
const Validator* v() const { return resolver_->GetValidatorForTesting(); }
/// Returns the statement that holds the given expression.
/// @param expr the ast::Expression
/// @return the ast::Statement of the ast::Expression, or nullptr if the

View File

@ -15,13 +15,13 @@
#include "src/tint/resolver/validator.h"
#include "gmock/gmock.h"
#include "src/tint/resolver/validator_test_helper.h"
#include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/atomic_type.h"
namespace tint::resolver {
namespace {
using ValidatorIsStorableTest = ValidatorTest;
using ValidatorIsStorableTest = ResolverTest;
TEST_F(ValidatorIsStorableTest, Void) {
EXPECT_FALSE(v()->IsStorable(create<sem::Void>()));

View File

@ -1,27 +0,0 @@
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/resolver/validator_test_helper.h"
#include <memory>
namespace tint::resolver {
TestHelper::TestHelper()
: validator_(
std::make_unique<Validator>(this->Symbols(), this->Diagnostics())) {}
TestHelper::~TestHelper() = default;
} // namespace tint::resolver

View File

@ -1,46 +0,0 @@
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_TINT_RESOLVER_VALIDATOR_TEST_HELPER_H_
#define SRC_TINT_RESOLVER_VALIDATOR_TEST_HELPER_H_
#include <memory>
#include "gtest/gtest.h"
#include "src/tint/program_builder.h"
#include "src/tint/resolver/validator.h"
namespace tint::resolver {
/// Helper class for testing
class TestHelper : public ProgramBuilder {
public:
/// Constructor
TestHelper();
/// Destructor
~TestHelper() override;
/// @return a pointer to the Validator
Validator* v() const { return validator_.get(); }
private:
std::unique_ptr<Validator> validator_;
};
class ValidatorTest : public TestHelper, public testing::Test {};
} // namespace tint::resolver
#endif // SRC_TINT_RESOLVER_VALIDATOR_TEST_HELPER_H_

View File

@ -274,6 +274,7 @@ tint_unittests_source_set("tint_unittests_resolver_src") {
"../../src/tint/resolver/type_constructor_validation_test.cc",
"../../src/tint/resolver/type_validation_test.cc",
"../../src/tint/resolver/validation_test.cc",
"../../src/tint/resolver/validator_is_storeable_test.cc",
"../../src/tint/resolver/var_let_test.cc",
"../../src/tint/resolver/var_let_validation_test.cc",
]