Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up type checking tests #1339

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
D = Steep::Diagnostic

FileUtils.mkpath("tmp")
tmp_rbs_dir = Pathname("tmp/rbs-sig")

definition = Bundler::Definition.build(Pathname("Gemfile"), Pathname("Gemfile.lock"), nil)
rbs_dep = definition.dependencies.find {|dep| dep.name == "rbs" }
if (source = rbs_dep&.source).is_a?(Bundler::Source::Path)
unless tmp_rbs_dir.directory?
FileUtils.ln_s(Pathname.pwd + source.path + "sig", tmp_rbs_dir.to_s, force: true)
end
else
FileUtils.rm_f(tmp_rbs_dir)
library "rbs"
end

target :app do
collection_config "rbs_collection.steep.yaml"

check "lib"
ignore "lib/steep/shims"

signature "sig"

collection_config "rbs_collection.steep.yaml"
ignore_signature "sig/test"

configure_code_diagnostics(D::Ruby.strict) do |hash|
end

FileUtils.mkpath("tmp")
tmp_rbs_dir = File.join("tmp", "rbs-sig")
if tmp_rbs_dir.directory?
signature tmp_rbs_dir.to_s
else
library "rbs"
end
end

target :test do
collection_config "rbs_collection.steep.yaml"

unreferenced!

check "test"
signature "sig/test"

configure_code_diagnostics(D::Ruby.lenient)

definition = Bundler::Definition.build(Pathname("Gemfile"), Pathname("Gemfile.lock"), nil)
rbs_dep = definition.dependencies.find {|dep| dep.name == "rbs" }
if (source = rbs_dep&.source).is_a?(Bundler::Source::Path)
unless Pathname(tmp_rbs_dir).exist?
FileUtils.ln_s(Pathname.pwd + source.path + "sig", tmp_rbs_dir, force: true)
end
signature tmp_rbs_dir
if tmp_rbs_dir.directory?
signature tmp_rbs_dir.to_s
else
FileUtils.rm_f(tmp_rbs_dir)
library "rbs"
end
end
19 changes: 19 additions & 0 deletions bin/rbs-inline
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

BINSTUB_DIR=$(cd $(dirname $0); pwd)
GEMFILE=$(readlink -f ${BINSTUB_DIR}/../gemfile_steep/Gemfile)
ROOT_DIR=$(readlink -f ${BINSTUB_DIR}/..)

RBSINLINE="bundle exec --gemfile=${GEMFILE} rbs-inline"

if type "rbenv" > /dev/null 2>&1; then
RBSINLINE="rbenv exec ${RBSINLINE}"
else
if type "rvm" > /dev/null 2>&1; then
if [ -e ${ROOT_DIR}/.ruby-version ]; then
RBS="rvm ${ROOT_DIR} do ${RBSINLINE}"
fi
fi
fi

exec $RBSINLINE $@
1 change: 1 addition & 0 deletions gemfile_steep/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source "https://rubygems.org"

gem 'steep', "~> 1.9.0.dev", require: false
gem "rbs-inline", require: false
5 changes: 5 additions & 0 deletions gemfile_steep/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ GEM
parser (3.3.6.0)
ast (~> 2.4.1)
racc
prism (1.2.0)
racc (1.8.1)
rainbow (3.1.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.7.0.dev.1)
logger
rbs-inline (0.10.0)
prism (>= 0.29, < 1.3)
rbs (>= 3.5.0)
securerandom (0.3.2)
steep (1.9.0.dev.1)
activesupport (>= 5.1)
Expand Down Expand Up @@ -76,6 +80,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
rbs-inline
steep (~> 1.9.0.dev)

BUNDLED WITH
Expand Down
23 changes: 23 additions & 0 deletions sig/test/annotation_collection_test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated from test/annotation_collection_test.rb with RBS::Inline

class AnnotationCollectionTest < Minitest::Test
include TestHelper

include FactoryHelper

Annotation: untyped

Types: untyped

AST: untyped

def new_collection: (current_module: untyped, factory: untyped) -> untyped

RBIS: ::Hash[untyped, untyped]

def test_types: () -> untyped

def test_dynamics: () -> untyped

def test_merge_block_annotations: () -> untyped
end
53 changes: 53 additions & 0 deletions sig/test/annotation_parsing_test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated from test/annotation_parsing_test.rb with RBS::Inline

class AnnotationParsingTest < Minitest::Test
include TestHelper

include ASTAssertion

include FactoryHelper

AnnotationParser: untyped

Annotation: untyped

Types: untyped

def parse_type: (untyped src, factory: untyped) -> untyped

def parse_annotation: (untyped source, factory: untyped) -> untyped

def test_skip_annotation: () -> untyped

def test_var_type_annotation: () -> untyped

def test_method_annotation: () -> untyped

def test_return_type_annotation: () -> untyped

def test_block_type_annotation: () -> untyped

def test_self_type: () -> untyped

def test_const_type: () -> untyped

def test_const_type2: () -> untyped

def test_const_type3: () -> untyped

def test_instance_type: () -> untyped

def test_module_type: () -> untyped

def test_implements: () -> untyped

def test_implement2: () -> untyped

def test_ivar_type: () -> untyped

def test_dynamic: () -> untyped

def test_break: () -> untyped

def test_annotation_syntax_error: () -> untyped
end
59 changes: 59 additions & 0 deletions sig/test/args_test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated from test/args_test.rb with RBS::Inline

class ArgsTest < Minitest::Test
include TestHelper

include FactoryHelper

SendArgs: untyped

Params: untyped

Types: untyped

AST: untyped

def around: () -> untyped

def method_name: () -> untyped

def parse_args: (untyped source) -> untyped

def test_positional_single_arg: () -> untyped

def test_positional_no_arg: () -> untyped

def test_positional_consume: () -> untyped

def test_positional_rest_arg: () -> untyped

def test_keyword_single_keyword_arg: () -> untyped

def test_keyword_single_keyword_no_arg: () -> untyped

def test_keyword_single_rocket_arg: () -> untyped

def test_keyword_splat_arg: () -> untyped

def test_keyword_consume_keys: () -> untyped

def test_compat_keyword_positional_arg: () -> untyped

def test_block_pass_arg: () -> untyped

def test_each_single_args: () -> untyped

def test_each_missing_arg: () -> untyped

def test_each_splat_tuple: () -> untyped

def test_each_splat_array: () -> untyped

def test_each_keyword_arg: () -> untyped

def test_each_keyword_arg_splat_record: () -> untyped

def test_each_keyword_arg_splat_array: () -> untyped

def test_forwarded_args: () -> untyped
end
19 changes: 19 additions & 0 deletions sig/test/ast/ignore_test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated from test/ast/ignore_test.rb with RBS::Inline

class AST__IgnoreTest < Minitest::Test
include TestHelper

Ignore: untyped

def parse: (untyped ruby) -> untyped

def test_parse_ignore_start: () -> untyped

def test_parse_ignore_end: () -> untyped

def test_parse_ignore__empty: () -> untyped

def test_parse_ignore__all: () -> untyped

def test_parse_ignore__diagnostics: () -> untyped
end
15 changes: 15 additions & 0 deletions sig/test/ast/node/type_application_test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated from test/ast/node/type_application_test.rb with RBS::Inline

class AST__Node__TypeApplicationTest < Minitest::Test
include TestHelper

include FactoryHelper

include SubtypingHelper

def buffer: (untyped string) -> untyped

def test_one_type: () -> untyped

def test_sequence_type: () -> untyped
end
15 changes: 15 additions & 0 deletions sig/test/ast/node/type_assertion_test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated from test/ast/node/type_assertion_test.rb with RBS::Inline

class AST__Node__TypeAssertionTest < Minitest::Test
include TestHelper

include FactoryHelper

include SubtypingHelper

def buffer: (untyped string) -> untyped

def test_type: () -> untyped

def test_relative_type: () -> untyped
end
59 changes: 59 additions & 0 deletions sig/test/block_params_test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated from test/block_params_test.rb with RBS::Inline

class BlockParamsTest < Minitest::Test
include TestHelper

include FactoryHelper

include SubtypingHelper

BlockParams: untyped

Params: untyped

Types: untyped

Namespace: untyped

def block_params: (untyped src) -> untyped

def test_1: () -> untyped

def test_2: () -> untyped

def test_zip1: () -> untyped

def test_zip2: () -> untyped

def test_zip3: () -> untyped

def test_zip4: () -> untyped

def test_zip_missing_required_params: () -> untyped

def test_zip_with_extra_params: () -> untyped

def test_zip_expand_array: () -> untyped

def test_zip_expand_tuple: () -> untyped

def test_param_type: () -> untyped

def test_param_type_with_annotation: () -> untyped

def test_param_type_with_hint: () -> untyped

def param_type: (?required: untyped, ?optional: untyped, ?rest: untyped, ?required_keywords: untyped, ?optional_keywords: untyped, ?rest_keywords: untyped) -> untyped

def test_zip_block: () -> untyped

def test_multiple_param_parse: () -> untyped

def test_multiple_param_zip: () -> untyped

def test_zip_untyped: () -> untyped

def test_unnamed: () -> untyped

def test_unnamed_multi: () -> untyped
end
Loading