Skip to content

Commit

Permalink
Add —junit_output_path for more granular control of the junit outpu…
Browse files Browse the repository at this point in the history
…t location
  • Loading branch information
Sija committed Dec 24, 2019
1 parent 62b6723 commit 20b9bf0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@

LLVM_CONFIG ?= ## llvm-config command path to use

release ?= ## Compile in release mode
stats ?= ## Enable statistics output
progress ?= ## Enable progress output
threads ?= ## Maximum number of threads to use
debug ?= ## Add symbolic debug info
verbose ?= ## Run specs in verbose mode
junit_output ?= ## Directory to output junit results
static ?= ## Enable static linking
release ?= ## Compile in release mode
stats ?= ## Enable statistics output
progress ?= ## Enable progress output
threads ?= ## Maximum number of threads to use
debug ?= ## Add symbolic debug info
verbose ?= ## Run specs in verbose mode
junit_output ?= ## Directory to output junit results
junit_output_path ?= ## Path to output junit results
static ?= ## Enable static linking

O := .build
SOURCES := $(shell find src -name '*.cr')
SPEC_SOURCES := $(shell find spec -name '*.cr')
override FLAGS += $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static )$(if $(LDFLAGS),--link-flags="$(LDFLAGS)" )
SPEC_WARNINGS_OFF := --exclude-warnings spec/std --exclude-warnings spec/compiler
SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_output) )
SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_output) )$(if $(junit_output_path),--junit_output_path $(junit_output_path) )
CRYSTAL_CONFIG_BUILD_COMMIT := $(shell git rev-parse --short HEAD 2> /dev/null)
EXPORTS := \
$(if $(release),,CRYSTAL_CONFIG_PATH="$(PWD)/src") \
Expand Down
8 changes: 6 additions & 2 deletions src/spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ OptionParser.parse do |opts|
abort("order must be either 'default', 'random', or a numeric seed value")
end
end
opts.on("--junit_output OUTPUT_DIR", "generate JUnit XML output") do |output_dir|
junit_formatter = Spec::JUnitFormatter.file(output_dir)
opts.on("--junit_output OUTPUT_DIR", "generate JUnit XML output within the given OUTPUT_DIR") do |output_dir|
junit_formatter = Spec::JUnitFormatter.file(Path[output_dir, "output.xml"])
Spec.add_formatter(junit_formatter)
end
opts.on("--junit_output_path OUTPUT_PATH", "generate JUnit XML output under the given OUTPUT_PATH") do |output_path|
junit_formatter = Spec::JUnitFormatter.file(Path[output_path])
Spec.add_formatter(junit_formatter)
end
opts.on("--help", "show this help") do |pattern|
Expand Down
7 changes: 3 additions & 4 deletions src/spec/junit_formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ module Spec
io.close
end

def self.file(output_dir)
Dir.mkdir_p(output_dir)
output_file_path = File.join(output_dir, "output.xml")
file = File.new(output_file_path, "w")
def self.file(output_path : Path)
Dir.mkdir_p(output_path.dirname)
file = File.new(output_path, "w")
JUnitFormatter.new(file)
end

Expand Down

0 comments on commit 20b9bf0

Please sign in to comment.