Skip to content

Forward exitcode from checkstyle execution #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bin/codeclimate-checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))

require "cc/engine/checkstyle"

if File.exist?("/config.json")
engine_config = JSON.parse(File.read("/config.json"))
config_file = ARGV[0] || "/config.json"

if File.exist?(config_file)
engine_config = JSON.parse(File.read(config_file))
else
engine_config = {}
end

CC::Engine::Checkstyle.new("/code", engine_config, STDOUT).run
exit($?.exitstatus)
File renamed without changes.
6 changes: 6 additions & 0 deletions fixtures/default/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"enabled": true,
"include_paths": [
"/usr/src/app/fixtures/default/Main.java"
]
}
31 changes: 31 additions & 0 deletions fixtures/not_parseable/Template.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Generated by Mavanagaiata ${MAVANAGAIATA_VERSION} at ${TIMESTAMP}
*/

package ${PACKAGE_NAME};

public final class ${CLASS_NAME} {

public static final String BRANCH = "${BRANCH}";

public static final String COMMIT_ABBREV = "${COMMIT_ABBREV}";

public static final String COMMIT_SHA = "${COMMIT_SHA}";

public static final String DESCRIBE = "${DESCRIBE}";

public static final boolean DIRTY = ${DIRTY};

public static final String TAG = "${TAG_NAME}";

public static final String VERSION = "${VERSION}";

public static String getVersion() {
if (TAG.equals(VERSION) && TAG.equals(DESCRIBE)) {
return TAG;
}

return String.format("%s (%s)", VERSION, DESCRIBE);
}

}
6 changes: 6 additions & 0 deletions fixtures/not_parseable/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"enabled": true,
"include_paths": [
"/usr/src/app/fixtures/not_parseable/Template.java"
]
}
8 changes: 4 additions & 4 deletions spec/lib/cc/engine/checkstyle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ module Engine
end

it "uses default config" do
run_with("include_paths" => ["fixtures/Main.java"])
run_with("include_paths" => ["fixtures/default/Main.java"])
end

it "accepts config path" do
run_with(
"config" => "config/codeclimate_checkstyle.xml",
"include_paths" => ["fixtures/Main.java"],
"include_paths" => ["fixtures/default/Main.java"],
)
end

it "accepts config hash" do
run_with(
"config" => { "file" => "config/codeclimate_checkstyle.xml" },
"include_paths" => ["fixtures/Main.java"],
"include_paths" => ["fixtures/default/Main.java"],
)
end

it "accepts config hash without file" do
run_with(
"config" => { "key" => "value" },
"include_paths" => ["fixtures/Main.java"],
"include_paths" => ["fixtures/default/Main.java"],
)
end

Expand Down
10 changes: 9 additions & 1 deletion spec/sanity_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

describe "Sanity Check" do
it "executes successfully with default config" do
pid, _, out, err = POSIX::Spawn.popen4("/usr/src/app/bin/codeclimate-checkstyle")
pid, _, out, err = POSIX::Spawn.popen4("/usr/src/app/bin/codeclimate-checkstyle", "/usr/src/app/fixtures/default/config.json")
_, status = Process::waitpid2(pid)

expect(status.exitstatus).to eq(0)
expect(err.read).to be_empty
end

it "forwards exit code" do
pid, _, out, err = POSIX::Spawn.popen4("/usr/src/app/bin/codeclimate-checkstyle", "/usr/src/app/fixtures/not_parseable/config.json")
_, status = Process::waitpid2(pid)

expect(status.exitstatus).to_not eq(0)
expect(err.read).to_not be_empty
end
end
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy