Skip to content

Commit

Permalink
Merge pull request #184 from PragTob/0.12.1-release
Browse files Browse the repository at this point in the history
0.12.1 release
  • Loading branch information
PragTob committed Feb 26, 2018
2 parents 14e4f97 + f2c9eae commit 33346bf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.12.1 (2018-02-26)

### Bugfixes (User Facing)
* Formatters that use `FileCreation.each` will no longer silently fail on file
creation and now also sanitizes `/` and other file name characters to be `_`.
Thanks @gfvcastro

## 0.12.0 (2018-01-20)

Adds the ability to save benchmarking results and load them again to compare
Expand Down
7 changes: 5 additions & 2 deletions lib/benchee/utility/file_creation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Benchee.Utility.FileCreation do
ensure_directory_exists filename
Enum.each names_to_content, fn({input_name, content}) ->
input_filename = interleave(filename, input_name)
File.open input_filename, [:write, :utf8], fn(file) ->
File.open! input_filename, [:write, :utf8], fn(file) ->
function.(file, content, input_filename)
end
end
Expand Down Expand Up @@ -68,6 +68,9 @@ defmodule Benchee.Utility.FileCreation do
iex> Benchee.Utility.FileCreation.interleave("abc.csv", "Big Input")
"abc_big_input.csv"
iex> Benchee.Utility.FileCreation.interleave("abc.csv", "String.length/1")
"abc_string_length_1.csv"
iex> Benchee.Utility.FileCreation.interleave("bench/abc.csv", "Big Input")
"bench/abc_big_input.csv"
Expand Down Expand Up @@ -123,7 +126,7 @@ defmodule Benchee.Utility.FileCreation do
case name_string do
^no_input -> ""
_ ->
String.downcase(String.replace(name_string, " ", "_"))
String.downcase(String.replace(name_string, ~r/[^0-9A-Z]/i, "_"))
end
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Benchee.Mixfile do
use Mix.Project

@version "0.12.0"
@version "0.12.1"

def project do
[
Expand Down
12 changes: 11 additions & 1 deletion test/benchee/utility/file_creation_integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Benchee.Utility.FileCreationIntegrationTest do
end
end

test "by default writes writes files" do
test "by default writes files" do
try do
capture_io fn -> each @input_to_contents, @filename end
assert_correct_files()
Expand All @@ -44,6 +44,16 @@ defmodule Benchee.Utility.FileCreationIntegrationTest do
end
end

test "with String.length/1 as a name it writes the correct file" do
to_contents = %{
"String.length/1" => "abc"
}
capture_io fn -> each to_contents, @filename end
assert File.exists? "#{@directory}/test_string_length_1.txt"
after
File.rm_rf! @directory
end

defp assert_correct_files do
assert File.exists? @file_name_1
assert File.exists? @file_name_2
Expand Down

0 comments on commit 33346bf

Please sign in to comment.