Skip to content

Commit

Permalink
Make sure that in error tests there are no variable values.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Sep 18, 2023
1 parent de0254c commit 493b94f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spec/errors/asset_directive_expected_file
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ component Main {

The path specified for an asset directive does not exist:

/home/gus/Projects/mint-lang/mint/spec/errors/path
path

The asset directive in question is here:

Expand Down
2 changes: 1 addition & 1 deletion spec/errors/inline_directive_expected_file
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ component Main {

The path specified for an inline directive does not exist:

/home/gus/Projects/mint-lang/mint/spec/errors/path
path

The inline directive in question is here:

Expand Down
2 changes: 1 addition & 1 deletion spec/errors/svg_directive_expected_file
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ component Main {

The specified file for an svg directive does not exist:

/home/gus/Projects/mint-lang/mint/fixtures/icon-missing
../../fixtures/icon-missing

The svg directive in question is here:

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "spec"

ENV["SPEC"] = "TRUE"
MINT_ENV["TEST"] = "TRUE"

def diff(a, b)
Expand Down
8 changes: 7 additions & 1 deletion src/type_checkers/directives/asset.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ module Mint
def check(node : Ast::Directives::Asset) : Checkable
error! :asset_directive_expected_file do
block "The path specified for an asset directive does not exist: "
snippet node.real_path.to_s

if ENV["SPEC"]?
snippet node.path.to_s
else
snippet node.real_path.to_s
end

snippet "The asset directive in question is here:", node
end unless node.exists?

Expand Down
8 changes: 7 additions & 1 deletion src/type_checkers/directives/inline.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ module Mint
def check(node : Ast::Directives::Inline) : Checkable
error! :inline_directive_expected_file do
block "The path specified for an inline directive does not exist:"
snippet node.real_path.to_s

if ENV["SPEC"]?
snippet node.path.to_s
else
snippet node.real_path.to_s
end

snippet "The inline directive in question is here:", node
end unless node.exists?

Expand Down
10 changes: 7 additions & 3 deletions src/type_checkers/directives/svg.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ module Mint
class TypeChecker
def check(node : Ast::Directives::Svg) : Checkable
error! :svg_directive_expected_file do
snippet(
"The specified file for an svg directive does not exist:",
node.real_path.to_s)
path =
if ENV["SPEC"]?
node.path.to_s
else
node.real_path.to_s
end

snippet "The specified file for an svg directive does not exist:", path
snippet "The svg directive in question is here:", node
end unless node.exists?

Expand Down

0 comments on commit 493b94f

Please sign in to comment.