Skip to content

Commit

Permalink
chore: sync with ecsact_common (#216)
Browse files Browse the repository at this point in the history
Co-authored-by: seaubot <[email protected]>
Co-authored-by: Ezekiel Warren <[email protected]>
  • Loading branch information
3 people authored May 24, 2024
1 parent 31ab9de commit b97c452
Show file tree
Hide file tree
Showing 23 changed files with 212 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.1
7.1.2
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

23 changes: 16 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@
name: main

on:
push:
branches:
- "**"
pull_request:
merge_group:

jobs:
typos-check:
name: Typos Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/[email protected]

formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jidicula/[email protected]
with: { clang-format-version: "16" }
- uses: greut/eclint-action@v0
- uses: jidicula/[email protected]
with: { clang-format-version: "18" }

test-windows:
if: github.event_name == 'merge_group'
runs-on: windows-latest
steps:
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
/Users/runneradmin/AppData/Local/bazelisk
Expand All @@ -33,9 +41,10 @@ jobs:
working-directory: test

test-linux:
if: github.event_name == 'merge_group'
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cache/bazelisk
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ All notable changes to this project will be documented in this file. See [conven

- - -

Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
3 changes: 0 additions & 3 deletions bazel/common.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ build --enable_runfiles
build --noincompatible_remove_rule_name_parameter
query --noincompatible_remove_rule_name_parameter

# Temporary until https://github.com/grailbio/bazel-toolchain/pull/198 is merged
build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux

common:ci --announce_rc
common:ci --verbose_failures
common:ci --keep_going
Expand Down
1 change: 1 addition & 0 deletions cog.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pre_bump_hooks = [
# Ecsact pre 1.0.0 the 0.X.0 is our 'major' version
"buildozer 'set version {{version}}' 'set compatibility_level {{version.minor}}' //MODULE.bazel:%module",
"bazel mod tidy",
]

post_bump_hooks = [
Expand Down
2 changes: 1 addition & 1 deletion ecsact/interpret/detail/file_eval_error.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace ecsact::detail {

void check_file_eval_error(
ecsact_eval_error& inout_error,
ecsact_eval_error& in_out_error,
ecsact_package_id package_id,
ecsact_parse_status status,
const ecsact_statement& statement,
Expand Down
28 changes: 19 additions & 9 deletions ecsact/interpret/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ static auto statement_param( //
template<>
auto statement_param<int32_t>( //
const ecsact_statement& statement,
std::string_view param_name
std::string_view in_param_name
) -> std::optional<int32_t> {
auto result = std::optional<int32_t>{};
for(auto& param : view_statement_params(statement)) {
if(std::string_view{param.name.data, static_cast<size_t>(param.name.length)} != param_name) {
auto param_name =
std::string_view{param.name.data, static_cast<size_t>(param.name.length)};
if(param_name != in_param_name) {
continue;
}

Expand All @@ -114,7 +116,10 @@ auto statement_param<bool>( //
) -> std::optional<bool> {
auto result = std::optional<bool>{};
for(auto& param : view_statement_params(statement)) {
if(std::string_view{param.name.data, static_cast<size_t>(param.name.length)} != param_name) {
if(std::string_view{
param.name.data,
static_cast<size_t>(param.name.length)
} != param_name) {
continue;
}

Expand Down Expand Up @@ -727,7 +732,11 @@ static ecsact_eval_error eval_system_statement(
return err;
}

if(auto err = allow_statement_params(statement, context, std::array{"lazy"sv, "parallel"sv})) {
if(auto err = allow_statement_params(
statement,
context,
std::array{"lazy"sv, "parallel"sv}
)) {
return *err;
}

Expand Down Expand Up @@ -802,7 +811,8 @@ static ecsact_eval_error eval_action_statement(
return err;
}

if(auto err = allow_statement_params(statement, context, std::array{"parallel"sv})) {
if(auto err =
allow_statement_params(statement, context, std::array{"parallel"sv})) {
return *err;
}

Expand Down Expand Up @@ -1757,13 +1767,13 @@ void ecsact_eval_reset() {
}

void ecsact::detail::check_file_eval_error(
ecsact_eval_error& inout_error,
ecsact_eval_error& in_out_error,
ecsact_package_id package_id,
ecsact_parse_status status,
const ecsact_statement& statement,
const std::string& source
) {
assert(inout_error.code == ECSACT_EVAL_OK);
assert(in_out_error.code == ECSACT_EVAL_OK);

if(status.code == ECSACT_PARSE_STATUS_BLOCK_END) {
if(statement.type == ECSACT_STATEMENT_ACTION) {
Expand All @@ -1776,8 +1786,8 @@ void ecsact::detail::check_file_eval_error(

auto caps = ecsact::meta::system_capabilities(*act_id);
if(caps.empty()) {
inout_error.code = ECSACT_EVAL_ERR_NO_CAPABILITIES;
inout_error.relevant_content = {
in_out_error.code = ECSACT_EVAL_ERR_NO_CAPABILITIES;
in_out_error.relevant_content = {
.data = source.c_str(),
.length = static_cast<int32_t>(source.size()),
};
Expand Down
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"extends": [
"github>ecsact-dev/renovate-config"
]
}
}
22 changes: 11 additions & 11 deletions test/comment_before_package.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test_lib.hh"

TEST(NoPackageStatementFirst, NoPackageStatementFirst) {
auto errs = ecsact_interpret_test_files({"comment_before_package.ecsact"});
ASSERT_EQ(errs.size(), 0) //
<< "Expected no errors. Instead got: " << errs[0].error_message << "\n";
}

#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test_lib.hh"

TEST(NoPackageStatementFirst, NoPackageStatementFirst) {
auto errs = ecsact_interpret_test_files({"comment_before_package.ecsact"});
ASSERT_EQ(errs.size(), 0) //
<< "Expected no errors. Instead got: " << errs[0].error_message << "\n";
}
8 changes: 4 additions & 4 deletions test/comment_before_package.ecsact
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Comments are allowed before the package statement
package test.comment_before_package;
// Comments are allowed before the package statement

package test.comment_before_package;

22 changes: 11 additions & 11 deletions test/errors/no_package_statement_first.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test_lib.hh"

TEST(NoPackageStatementFirst, NoPackageStatementFirst) {
auto errs =
ecsact_interpret_test_files({"errors/no_package_statement_first.ecsact"});
ASSERT_EQ(errs.size(), 1);
ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_EXPECTED_PACKAGE_STATEMENT);
}
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test_lib.hh"

TEST(NoPackageStatementFirst, NoPackageStatementFirst) {
auto errs =
ecsact_interpret_test_files({"errors/no_package_statement_first.ecsact"});
ASSERT_EQ(errs.size(), 1);
ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_EXPECTED_PACKAGE_STATEMENT);
}
14 changes: 7 additions & 7 deletions test/errors/no_package_statement_first.ecsact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
component ExampleComponent {
f32 num;
}
// Package statement must be first
package errors.no_pkg_statement_first;
component ExampleComponent {
f32 num;
}

// Package statement must be first
package errors.no_pkg_statement_first;

22 changes: 11 additions & 11 deletions test/errors/unknown_association_field.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test_lib.hh"

TEST(InterpretError, UnknownAssociationField) {
auto errs =
ecsact_interpret_test_files({"errors/unknown_association_field.ecsact"});
ASSERT_EQ(errs.size(), 1);
ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_FIELD_NAME_ALREADY_EXISTS);
}
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test_lib.hh"

TEST(InterpretError, UnknownAssociationField) {
auto errs =
ecsact_interpret_test_files({"errors/unknown_association_field.ecsact"});
ASSERT_EQ(errs.size(), 1);
ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_FIELD_NAME_ALREADY_EXISTS);
}
24 changes: 12 additions & 12 deletions test/errors/unknown_association_field.ecsact
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package unknown_association_field;
component ComponentWithAssoc {
entity foo;
}
system MySystem {
readwrite ComponentWithAssoc with bar {
readwrite ComponentWithAssoc;
}
}
package unknown_association_field;

component ComponentWithAssoc {
entity foo;
}

system MySystem {
readwrite ComponentWithAssoc with bar {
readwrite ComponentWithAssoc;
}
}

58 changes: 29 additions & 29 deletions test/extra/extra.cc
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"
#include "ecsact/runtime/meta.hh"

#include "test_lib.hh"

TEST(MultiPkgTest, NoErrors) {
auto errs = ecsact_interpret_test_files({
"extra/imported_pkg.ecsact",
"extra/runtime_test.ecsact",
});
EXPECT_EQ(errs.size(), 0) //
<< "Expected no errors. Instead got: " << errs[0].error_message << "\n";

EXPECT_EQ(ecsact_meta_count_packages(), 2);

auto pkg_ids = ecsact::meta::get_package_ids();
for(auto pkg_id : pkg_ids) {
auto pkg_name = ecsact::meta::package_name(pkg_id);

if(pkg_name == "runtime_test") {
EXPECT_EQ(ecsact_meta_count_dependencies(pkg_id), 1) //
<< "Expected main package to have 3 dependencies. One for each import";
} else if(pkg_name == "imported.test_pkg") {
} else {
EXPECT_TRUE(false) << "No tests for package: " << pkg_name;
}
}
}
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"
#include "ecsact/runtime/meta.hh"

#include "test_lib.hh"

TEST(MultiPkgTest, NoErrors) {
auto errs = ecsact_interpret_test_files({
"extra/imported_pkg.ecsact",
"extra/runtime_test.ecsact",
});
EXPECT_EQ(errs.size(), 0) //
<< "Expected no errors. Instead got: " << errs[0].error_message << "\n";

EXPECT_EQ(ecsact_meta_count_packages(), 2);

auto pkg_ids = ecsact::meta::get_package_ids();
for(auto pkg_id : pkg_ids) {
auto pkg_name = ecsact::meta::package_name(pkg_id);

if(pkg_name == "runtime_test") {
EXPECT_EQ(ecsact_meta_count_dependencies(pkg_id), 1) //
<< "Expected main package to have 3 dependencies. One for each import";
} else if(pkg_name == "imported.test_pkg") {
} else {
EXPECT_TRUE(false) << "No tests for package: " << pkg_name;
}
}
}
12 changes: 6 additions & 6 deletions test/extra/imported_pkg.ecsact
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package imported.test_pkg;
component ImportedComponent {
i32 num;
}
package imported.test_pkg;

component ImportedComponent {
i32 num;
}

Loading

0 comments on commit b97c452

Please sign in to comment.