-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Parser): set consistent opts
Move trace task to source-controlled dir. Update Trace
- Loading branch information
1 parent
0490486
commit 8cad8f2
Showing
6 changed files
with
308 additions
and
350 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
defmodule Mix.Tasks.ExFactorRunner do | ||
@moduledoc """ | ||
In order to run ExFactor on ExFactor, we need to make some files available "outside of" ExFactor, or more precisely along side of ExFactor. | ||
We need to have a process running during compilation that can run the `ExFactor.Server` Agent. | ||
Additionally we need the setup from `ExFactor.Traces`, we could replicate this here, but why | ||
bother copying something that we'll reuse. | ||
""" | ||
use Mix.Task | ||
|
||
@impl true | ||
def run(args) do | ||
unless Version.match?(System.version(), ">= 1.13.0") do | ||
Mix.raise("Elixir v1.13+ is required!") | ||
end | ||
|
||
Code.compiler_options(debug_info: true, parser_options: [columns: true, token_metadata: true]) | ||
|
||
Code.compile_file("./lib/ex_factor/server.ex", File.cwd!()) | ||
:timer.sleep(20) | ||
|
||
Code.compile_file("./lib/ex_factor/traces.ex", File.cwd!()) | ||
:timer.sleep(20) | ||
|
||
case args do | ||
[] -> | ||
|
||
do_run() | ||
|
||
_ -> | ||
Mix.raise("Additional CLI args are not supported.\n\n\tUsage: elixir -r support/trace_task.ex -S mix ex_factor_runner") | ||
end | ||
end | ||
|
||
defp do_run() do | ||
ExFactor.Traces.setup() | ||
|
||
Mix.Task.rerun("compile", ["--force", "--tracer=ExFactor.Tracer"]) |> IO.inspect(label: "") | ||
|
||
entries = ExFactor.Server.entries() | ||
entries_string = inspect(entries, limit: :infinity, printable_limit: :infinity) | ||
File.write!("./tmp/trace_entries", entries_string) | ||
|
||
file_contents = [ | ||
"defmodule ExFactor.Support.Trace do", | ||
"def trace_function do", | ||
entries_string, | ||
"end", | ||
"end" | ||
] | ||
|> Enum.join("\n") | ||
|
||
path = "./test/support/trace.ex" | ||
File.write!(path, file_contents) | ||
Mix.Tasks.Format.run([path]) | ||
end | ||
end |
Oops, something went wrong.