Skip to content

Commit

Permalink
Merge branch 'master' into ranges-union_intersection_overlaps
Browse files Browse the repository at this point in the history
  • Loading branch information
CTC97 authored Oct 26, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
2 parents 75f9561 + 0e1018f commit 81b7e8a
Showing 19 changed files with 263 additions and 123 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/mingw-w64.yml
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

env:
SPEC_SPLIT_DOTS: 160

jobs:
x86_64-mingw-w64-cross-compile:
runs-on: ubuntu-24.04
@@ -89,3 +92,63 @@ jobs:
path: |
bin/
share/
x86_64-mingw-w64-test:
runs-on: windows-2022
needs: [x86_64-mingw-w64-link]
steps:
- name: Setup MSYS2
id: msys2
uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2.24.1
with:
msystem: UCRT64
update: true
install: >-
git
make
mingw-w64-ucrt-x86_64-pkgconf
mingw-w64-ucrt-x86_64-cc
mingw-w64-ucrt-x86_64-gc
mingw-w64-ucrt-x86_64-pcre2
mingw-w64-ucrt-x86_64-libiconv
mingw-w64-ucrt-x86_64-zlib
mingw-w64-ucrt-x86_64-llvm
mingw-w64-ucrt-x86_64-gmp
mingw-w64-ucrt-x86_64-libxml2
mingw-w64-ucrt-x86_64-libyaml
mingw-w64-ucrt-x86_64-openssl
mingw-w64-ucrt-x86_64-libffi
- name: Disable CRLF line ending substitution
run: |
git config --global core.autocrlf false
- name: Download Crystal source
uses: actions/checkout@v4

- name: Download Crystal executable
uses: actions/download-artifact@v4
with:
name: x86_64-mingw-w64-crystal
path: crystal

- name: Run stdlib specs
shell: msys2 {0}
run: |
export PATH="$(pwd)/crystal/bin:$PATH"
export CRYSTAL_SPEC_COMPILER_BIN="$(pwd)/crystal/bin/crystal.exe"
make std_spec
- name: Run compiler specs
shell: msys2 {0}
run: |
export PATH="$(pwd)/crystal/bin:$PATH"
export CRYSTAL_SPEC_COMPILER_BIN="$(pwd)/crystal/bin/crystal.exe"
make compiler_spec FLAGS=-Dwithout_ffi
- name: Run primitives specs
shell: msys2 {0}
run: |
export PATH="$(pwd)/crystal/bin:$PATH"
export CRYSTAL_SPEC_COMPILER_BIN="$(pwd)/crystal/bin/crystal.exe"
make -o .build/crystal.exe primitives_spec # we know the compiler is fresh; do not rebuild it here
50 changes: 25 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -68,10 +68,10 @@ CXXFLAGS += $(if $(debug),-g -O0)

# MSYS2 support (native Windows should use `Makefile.win` instead)
ifeq ($(OS),Windows_NT)
CRYSTAL_BIN := crystal.exe
EXE := .exe
WINDOWS := 1
else
CRYSTAL_BIN := crystal
EXE :=
WINDOWS :=
endif

@@ -112,28 +112,28 @@ test: spec ## Run tests
spec: std_spec primitives_spec compiler_spec

.PHONY: std_spec
std_spec: $(O)/std_spec ## Run standard library specs
$(O)/std_spec $(SPEC_FLAGS)
std_spec: $(O)/std_spec$(EXE) ## Run standard library specs
$(O)/std_spec$(EXE) $(SPEC_FLAGS)

.PHONY: compiler_spec
compiler_spec: $(O)/compiler_spec ## Run compiler specs
$(O)/compiler_spec $(SPEC_FLAGS)
compiler_spec: $(O)/compiler_spec$(EXE) ## Run compiler specs
$(O)/compiler_spec$(EXE) $(SPEC_FLAGS)

.PHONY: primitives_spec
primitives_spec: $(O)/primitives_spec ## Run primitives specs
$(O)/primitives_spec $(SPEC_FLAGS)
primitives_spec: $(O)/primitives_spec$(EXE) ## Run primitives specs
$(O)/primitives_spec$(EXE) $(SPEC_FLAGS)

.PHONY: interpreter_spec
interpreter_spec: $(O)/interpreter_spec ## Run interpreter specs
$(O)/interpreter_spec $(SPEC_FLAGS)
interpreter_spec: $(O)/interpreter_spec$(EXE) ## Run interpreter specs
$(O)/interpreter_spec$(EXE) $(SPEC_FLAGS)

.PHONY: smoke_test
smoke_test: ## Build specs as a smoke test
smoke_test: $(O)/std_spec $(O)/compiler_spec $(O)/$(CRYSTAL_BIN)
smoke_test: $(O)/std_spec$(EXE) $(O)/compiler_spec$(EXE) $(O)/$(CRYSTAL)$(EXE)

.PHONY: all_spec
all_spec: $(O)/all_spec ## Run all specs (note: this builds a huge program; `test` recipe builds individual binaries and is recommended for reduced resource usage)
$(O)/all_spec $(SPEC_FLAGS)
all_spec: $(O)/all_spec$(EXE) ## Run all specs (note: this builds a huge program; `test` recipe builds individual binaries and is recommended for reduced resource usage)
$(O)/all_spec$(EXE) $(SPEC_FLAGS)

.PHONY: samples
samples: ## Build example programs
@@ -146,7 +146,7 @@ docs: ## Generate standard library documentation
cp -av doc/ docs/

.PHONY: crystal
crystal: $(O)/$(CRYSTAL_BIN) ## Build the compiler
crystal: $(O)/$(CRYSTAL)$(EXE) ## Build the compiler

.PHONY: deps llvm_ext
deps: $(DEPS) ## Build dependencies
@@ -161,9 +161,9 @@ generate_data: ## Run generator scripts for Unicode, SSL config, ...
$(MAKE) -B -f scripts/generate_data.mk

.PHONY: install
install: $(O)/$(CRYSTAL_BIN) man/crystal.1.gz ## Install the compiler at DESTDIR
install: $(O)/$(CRYSTAL)$(EXE) man/crystal.1.gz ## Install the compiler at DESTDIR
$(INSTALL) -d -m 0755 "$(BINDIR)/"
$(INSTALL) -m 0755 "$(O)/$(CRYSTAL_BIN)" "$(BINDIR)/$(CRYSTAL_BIN)"
$(INSTALL) -m 0755 "$(O)/$(CRYSTAL)$(EXE)" "$(BINDIR)/$(CRYSTAL)$(EXE)"

$(INSTALL) -d -m 0755 $(DATADIR)
cp -av src "$(DATADIR)/src"
@@ -183,14 +183,14 @@ install: $(O)/$(CRYSTAL_BIN) man/crystal.1.gz ## Install the compiler at DESTDIR

ifeq ($(WINDOWS),1)
.PHONY: install_dlls
install_dlls: $(O)/$(CRYSTAL_BIN) ## Install the compiler's dependent DLLs at DESTDIR (Windows only)
install_dlls: $(O)/$(CRYSTAL)$(EXE) ## Install the compiler's dependent DLLs at DESTDIR (Windows only)
$(INSTALL) -d -m 0755 "$(BINDIR)/"
@ldd $(O)/$(CRYSTAL_BIN) | grep -iv ' => /c/windows/system32' | sed 's/.* => //; s/ (.*//' | xargs -t -i $(INSTALL) -m 0755 '{}' "$(BINDIR)/"
@ldd $(O)/$(CRYSTAL)$(EXE) | grep -iv ' => /c/windows/system32' | sed 's/.* => //; s/ (.*//' | xargs -t -i $(INSTALL) -m 0755 '{}' "$(BINDIR)/"
endif

.PHONY: uninstall
uninstall: ## Uninstall the compiler from DESTDIR
rm -f "$(BINDIR)/$(CRYSTAL_BIN)"
rm -f "$(BINDIR)/$(CRYSTAL)$(EXE)"

rm -rf "$(DATADIR)/src"

@@ -212,31 +212,31 @@ uninstall_docs: ## Uninstall docs from DESTDIR
rm -rf "$(DATADIR)/docs"
rm -rf "$(DATADIR)/examples"

$(O)/all_spec: $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(O)/all_spec$(EXE): $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(call check_llvm_config)
@mkdir -p $(O)
$(EXPORT_CC) $(EXPORTS) ./bin/crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec/all_spec.cr

$(O)/std_spec: $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(O)/std_spec$(EXE): $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(call check_llvm_config)
@mkdir -p $(O)
$(EXPORT_CC) ./bin/crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec/std_spec.cr

$(O)/compiler_spec: $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(O)/compiler_spec$(EXE): $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(call check_llvm_config)
@mkdir -p $(O)
$(EXPORT_CC) $(EXPORTS) ./bin/crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec/compiler_spec.cr --release

$(O)/primitives_spec: $(O)/$(CRYSTAL_BIN) $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(O)/primitives_spec$(EXE): $(O)/$(CRYSTAL)$(EXE) $(DEPS) $(SOURCES) $(SPEC_SOURCES)
@mkdir -p $(O)
$(EXPORT_CC) ./bin/crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec/primitives_spec.cr

$(O)/interpreter_spec: $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(O)/interpreter_spec$(EXE): $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(eval interpreter=1)
@mkdir -p $(O)
$(EXPORT_CC) ./bin/crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec/compiler/interpreter_spec.cr

$(O)/$(CRYSTAL_BIN): $(DEPS) $(SOURCES)
$(O)/$(CRYSTAL)$(EXE): $(DEPS) $(SOURCES)
$(call check_llvm_config)
@mkdir -p $(O)
@# NOTE: USE_PCRE1 is only used for testing compatibility with legacy environments that don't provide libpcre2.
2 changes: 1 addition & 1 deletion bin/crystal
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ esac
if [ -x "$CRYSTAL_DIR/${CRYSTAL_BIN}" ]; then
__warning_msg "Using compiled compiler at ${CRYSTAL_DIR#"$PWD/"}/${CRYSTAL_BIN}"
exec "$CRYSTAL_DIR/${CRYSTAL_BIN}" "$@"
elif !($PARENT_CRYSTAL_EXISTS); then
elif (! $PARENT_CRYSTAL_EXISTS); then
__error_msg 'You need to have a crystal executable in your path! or set CRYSTAL env variable'
exit 1
else
2 changes: 2 additions & 0 deletions spec/compiler/crystal/tools/doc/project_info_spec.cr
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ private alias ProjectInfo = Crystal::Doc::ProjectInfo

private def run_git(command)
Process.run(%(git -c user.email="" -c user.name="spec" #{command}), shell: true)
rescue IO::Error
pending! "Git is not available"
end

private def assert_with_defaults(initial, expected, *, file = __FILE__, line = __LINE__)
14 changes: 12 additions & 2 deletions spec/compiler/crystal/tools/init_spec.cr
Original file line number Diff line number Diff line change
@@ -41,9 +41,17 @@ private def run_init_project(skeleton_type, name, author, email, github_name, di
).run
end

private def git_available?
Process.run(Crystal::Git.executable).success?
rescue IO::Error
false
end

module Crystal
describe Init::InitProject do
it "correctly uses git config" do
pending! "Git is not available" unless git_available?

within_temporary_directory do
File.write(".gitconfig", <<-INI)
[user]
@@ -212,9 +220,11 @@ module Crystal
)
end

with_file "example/.git/config" { }
if git_available?
with_file "example/.git/config" { }

with_file "other-example-directory/.git/config" { }
with_file "other-example-directory/.git/config" { }
end
end
end
end
6 changes: 5 additions & 1 deletion spec/compiler/loader/unix_spec.cr
Original file line number Diff line number Diff line change
@@ -40,7 +40,11 @@ describe Crystal::Loader do
exc = expect_raises(Crystal::Loader::LoadError, /no such file|not found|cannot open/i) do
Crystal::Loader.parse(["-l", "foo/bar.o"], search_paths: [] of String)
end
exc.message.should contain File.join(Dir.current, "foo", "bar.o")
{% if flag?(:openbsd) %}
exc.message.should contain "foo/bar.o"
{% else %}
exc.message.should contain File.join(Dir.current, "foo", "bar.o")
{% end %}
end
end

17 changes: 11 additions & 6 deletions spec/std/exception/call_stack_spec.cr
Original file line number Diff line number Diff line change
@@ -55,14 +55,19 @@ describe "Backtrace" do
error.to_s.should contain("IndexError")
end

it "prints crash backtrace to stderr", tags: %w[slow] do
sample = datapath("crash_backtrace_sample")
{% if flag?(:openbsd) %}
# FIXME: the segfault handler doesn't work on OpenBSD
pending "prints crash backtrace to stderr"
{% else %}
it "prints crash backtrace to stderr", tags: %w[slow] do
sample = datapath("crash_backtrace_sample")

_, output, error = compile_and_run_file(sample)
_, output, error = compile_and_run_file(sample)

output.to_s.should be_empty
error.to_s.should contain("Invalid memory access")
end
output.to_s.should be_empty
error.to_s.should contain("Invalid memory access")
end
{% end %}

# Do not test this on platforms that cannot remove the current working
# directory of the process:
8 changes: 4 additions & 4 deletions spec/std/io/io_spec.cr
Original file line number Diff line number Diff line change
@@ -425,9 +425,9 @@ describe IO do
str.read_fully?(slice).should be_nil
end

# pipe(2) returns bidirectional file descriptors on FreeBSD and Solaris,
# pipe(2) returns bidirectional file descriptors on some platforms,
# gate this test behind the platform flag.
{% unless flag?(:freebsd) || flag?(:solaris) %}
{% unless flag?(:freebsd) || flag?(:solaris) || flag?(:openbsd) %}
it "raises if trying to read to an IO not opened for reading" do
IO.pipe do |r, w|
expect_raises(IO::Error, "File not open for reading") do
@@ -574,9 +574,9 @@ describe IO do
io.read_byte.should be_nil
end

# pipe(2) returns bidirectional file descriptors on FreeBSD and Solaris,
# pipe(2) returns bidirectional file descriptors on some platforms,
# gate this test behind the platform flag.
{% unless flag?(:freebsd) || flag?(:solaris) %}
{% unless flag?(:freebsd) || flag?(:solaris) || flag?(:openbsd) %}
it "raises if trying to write to an IO not opened for writing" do
IO.pipe do |r, w|
# unless sync is used the flush on close triggers the exception again
Loading

0 comments on commit 81b7e8a

Please sign in to comment.