From 5ac7a343a8fccd713200c512013ffc725d034809 Mon Sep 17 00:00:00 2001 From: Gustavo Villa Date: Thu, 22 Feb 2018 21:25:52 -0300 Subject: [PATCH 1/4] Update to_filename function pattern --- lib/benchee/utility/file_creation.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/benchee/utility/file_creation.ex b/lib/benchee/utility/file_creation.ex index 3b743af3..426a469a 100644 --- a/lib/benchee/utility/file_creation.ex +++ b/lib/benchee/utility/file_creation.ex @@ -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" @@ -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 From e6a6b9cdb27253724c855ccdd7de6f474f2528fb Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 23 Feb 2018 09:46:26 +0100 Subject: [PATCH 2/4] Integration test + fail on file creation --- lib/benchee/utility/file_creation.ex | 2 +- .../utility/file_creation_integration_test.exs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/benchee/utility/file_creation.ex b/lib/benchee/utility/file_creation.ex index 426a469a..006882f3 100644 --- a/lib/benchee/utility/file_creation.ex +++ b/lib/benchee/utility/file_creation.ex @@ -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 diff --git a/test/benchee/utility/file_creation_integration_test.exs b/test/benchee/utility/file_creation_integration_test.exs index 34cc98d4..dc34d7e5 100644 --- a/test/benchee/utility/file_creation_integration_test.exs +++ b/test/benchee/utility/file_creation_integration_test.exs @@ -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() @@ -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 From c094fe03525e05e3792a08804d1d1911e0d86185 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Mon, 26 Feb 2018 19:52:57 +0100 Subject: [PATCH 3/4] 0.12.1 changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3497cc86..ceec7870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From f2c9eae5795cefac15cf63dea799940e5c99e10f Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Mon, 26 Feb 2018 19:55:41 +0100 Subject: [PATCH 4/4] aaannndd 0.12.1 version bump --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 5394e333..ccf1b128 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Benchee.Mixfile do use Mix.Project - @version "0.12.0" + @version "0.12.1" def project do [