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

Match Nix loader errors in compiler spec #12852

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

bcardiff
Copy link
Member

As part of NixOS/nixpkgs#195606 I noticed that the compiler loader specs fails on nix.

This PR tweaks, an already long regex, to accept one more case similar to #12323

output of compiler spec failure on nix
  1) Crystal::Loader .parse parses file paths
     Failure/Error: expect_raises(Crystal::Loader::LoadError, /#{Dir.current}\/foobar\.o.+(No such file or directory|image not found)|Cannot open "#{Dir.current}\/foobar\.o"/) do

       Expected Crystal::Loader::LoadError with message matching /\/private\/tmp\/nix-build-crystal-1.6.2.drv-0\/source\/foobar\.o.+(No such file or directory|image not found)|Cannot open "\/private\/tmp\/nix-build-crystal-1.6.2.drv-0\/source\/foobar\.o"/, got #<Crystal::Loader::LoadError: cannot load /private/tmp/nix-build-crystal-1.6.2.drv-0/source/foobar.o (dlopen(/private/tmp/nix-build-crystal-1.6.2.drv-0/source/foobar.o, 0x0009): tried: '/private/tmp/nix-build-crystal-1.6.2.drv-0/source/foobar.o' (no such file))
       Linker arguments: foobar.o
       Search path: > with backtrace:
         # src/compiler/crystal/loader/unix.cr:84:25 in 'load_file'
         # src/compiler/crystal/loader.cr:39:7 in 'new'
         # src/compiler/crystal/loader/unix.cr:60:7 in 'parse:search_paths'
         # spec/compiler/loader/unix_spec.cr:32:9 in '->'
         # src/spec/example.cr:45:13 in 'internal_run'
         # src/spec/example.cr:33:16 in 'run'
         # src/spec/context.cr:18:23 in 'internal_run'
         # src/spec/context.cr:339:7 in 'run'
         # src/spec/context.cr:18:23 in 'internal_run'
         # src/spec/context.cr:339:7 in 'run'
         # src/spec/context.cr:18:23 in 'internal_run'
         # src/spec/context.cr:156:7 in 'run'
         # src/spec/dsl.cr:220:7 in '->'
         # src/crystal/at_exit_handlers.cr:14:19 in 'run'
         # src/crystal/main.cr:50:14 in 'exit'
         # src/crystal/main.cr:45:5 in 'main'
         # src/crystal/main.cr:127:3 in 'main'

     # spec/compiler/loader/unix_spec.cr:31

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:interpreter labels Dec 18, 2022
@straight-shoota
Copy link
Member

I'm wondering if we shouldn't simplify the spec a bit, instead of making it more complex for every new case we discover that doesn't match yet.

My idea would be to test that the error message contains the filename as well as either no such file or image not found (case-insensitive).

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to merge it as is, though.

@beta-ziliani beta-ziliani added this to the 1.7.0 milestone Dec 19, 2022
@straight-shoota straight-shoota merged commit 181ec63 into crystal-lang:master Dec 20, 2022
@bcardiff
Copy link
Member Author

Or even assert only the filename, I'm not sure we need the reason in this spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:interpreter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants