-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved warmup doc, performance and information
Attributes are prepended correctly Debugging in purity analyzer Version checking in tables implemented, but not used yet Peephole fix where parens unnecessary removed Versioning slightly improved tria.clean and tria.report tasks introduced README for tria.report improved
- Loading branch information
Showing
12 changed files
with
261 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
defmodule Mix.Tasks.Tria.Clean do | ||
use Mix.Task | ||
|
||
@moduledoc """ | ||
# Cache cleanup | ||
Tria uses cache ets files located in `priv` directory to | ||
optimize evaluation of some function traits like purity | ||
or safety. This manually deletes the caches. | ||
### Example: | ||
```sh | ||
mix tria.clean -y | ||
``` | ||
### Options | ||
* `-y` or `--yes` -- to skip confirmation step | ||
""" | ||
|
||
@shortdoc "Deletes tria cache files" | ||
|
||
def run(args) do | ||
priv = "#{:code.priv_dir(:tria)}" | ||
|
||
to_delete = | ||
priv | ||
|> File.ls!() | ||
|> Enum.flat_map(fn filename -> | ||
if String.ends_with?(filename, "_cache.ets") do | ||
priv | ||
|> Path.join(filename) | ||
|> info() | ||
|> List.wrap() | ||
else | ||
[] | ||
end | ||
end) | ||
|
||
confirmed? = | ||
with false <- args in [["-y"], ["--yes"]] do | ||
result = IO.gets("Confirm? [Y(yes); n(no)] ") in ["y\n", "Y\n", "\n"] | ||
unless result do | ||
IO.write [IO.ANSI.red(), "Denied. Nothing cleaned\n", IO.ANSI.reset()] | ||
end | ||
result | ||
end | ||
|
||
if confirmed? do | ||
Enum.each(to_delete, &File.rm/1) | ||
end | ||
end | ||
|
||
defp info(cache) do | ||
IO.write [ | ||
"Deleting file: ", | ||
IO.ANSI.green(), | ||
cache, | ||
IO.ANSI.reset(), | ||
"\n" | ||
] | ||
|
||
cache | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
defmodule Mix.Tasks.Tria.Report do | ||
use Mix.Task | ||
|
||
@moduledoc """ | ||
# Reports Tria bug | ||
Simple task which opens up your default web browser | ||
with all automatically gatherable information prefilled | ||
in a github issue in compiler's tracker | ||
### Example: | ||
Basically you may want to run something like this once | ||
```sh | ||
$ TRIA_DEBUG=1 mix compile > file.log | ||
$ mix tria.report "Bug in compilation" | ||
``` | ||
""" | ||
|
||
@shortdoc "Creates issue on compiler's tracker automatically" | ||
|
||
defmacrop safe(code) do | ||
quote do | ||
try do | ||
unquote(code) | ||
rescue | ||
_ -> nil | ||
end | ||
end | ||
end | ||
|
||
def run(args) do | ||
title = List.first(args) || "INSERT TITLE HERE" | ||
query = URI.encode_query(%{title: "Report: #{title}", body: body(title)}) | ||
uri = "https://github.com/hissssst/tria/issues/new?" <> query | ||
System.cmd("xdg-open", [uri]) | ||
end | ||
|
||
defp body(title) do | ||
""" | ||
# #{title} | ||
<!-- Short desription of an issue and a link to the source code here --> | ||
## Environment | ||
### Versions | ||
* System info: `#{safe inspect :os.type()} #{safe inspect :os.version()}` | ||
* Erlang: `#{safe List.to_string :erlang.system_info :system_version}` | ||
* Elixir: `#{safe System.version()}` | ||
* Tria: `#{Tria.version()}` | ||
### Configuration | ||
* compilers: `#{safe inspect Mix.Project.config()[:compilers]}` | ||
* protocol consolidation: `#{safe inspect Mix.Project.config()[:consolidate_protocols]}` | ||
* tria app env: `#{safe inspect Application.get_all_env(:tria)}` | ||
### System environment | ||
``` | ||
#{safe system_env()} | ||
``` | ||
## Expected behaiour | ||
<!-- Desription of how you think Tria should behave --> | ||
## Actual behaviour | ||
<!-- Desription of how Tria actually behaved --> | ||
## Steps to reproduce | ||
<!-- Steps to follow to reporduce the bug. The more precise the steps are, the better --> | ||
""" | ||
end | ||
|
||
@vars ~w[ | ||
TRIA_DEBUG | ||
TRIA_TRACE | ||
] | ||
|
||
defp system_env do | ||
Enum.map_join(@vars, "\n", fn var -> | ||
"#{var}=#{System.get_env(var)}" | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.