Skip to content
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

failed builds dirty checks #3834

Merged
merged 1 commit into from
Oct 26, 2018
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
14 changes: 9 additions & 5 deletions conans/client/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from conans.paths import CONANINFO, BUILD_INFO, RUN_LOG_NAME
from conans.util.env_reader import get_env
from conans.util.files import (save, rmdir, mkdir, make_read_only,
set_dirty, clean_dirty, load)
set_dirty, clean_dirty, load, is_dirty)
from conans.util.log import logger
from conans.util.tracer import log_package_built, \
log_package_got_from_local_cache
Expand Down Expand Up @@ -373,14 +373,16 @@ def _handle_node_workspace(self, node, workspace_package, inverse_levels, deps_g
def _build_package(self, node, package_ref, output, keep_build):
conan_ref, conan_file = node.conan_ref, node.conanfile

skip_build = conan_file.develop and keep_build
if skip_build:
output.info("Won't be built as specified by --keep-build")

t1 = time.time()
builder = _ConanPackageBuilder(conan_file, package_ref, self._client_cache, output,
self._plugin_manager)
if is_dirty(builder.build_folder):
output.warn("Build folder is dirty, removing it: %s" % builder.build_folder)
rmdir(builder.build_folder)

skip_build = conan_file.develop and keep_build
if skip_build:
output.info("Won't be built as specified by --keep-build")
if skip_build:
if not os.path.exists(builder.build_folder):
msg = "--keep-build specified, but build folder not found"
Expand All @@ -390,6 +392,7 @@ def _build_package(self, node, package_ref, output, keep_build):
raise ConanException(msg)
else:
with self._client_cache.conanfile_write_lock(conan_ref):
set_dirty(builder.build_folder)
complete_recipe_sources(self._remote_manager, self._client_cache,
self._registry, conan_file, conan_ref)
builder.prepare_build()
Expand All @@ -398,6 +401,7 @@ def _build_package(self, node, package_ref, output, keep_build):
try:
if not skip_build:
builder.build()
clean_dirty(builder.build_folder)
builder.package()
except ConanException as exc:
self._recorder.package_install_error(package_ref, INSTALL_ERROR_BUILDING,
Expand Down
30 changes: 30 additions & 0 deletions conans/test/integration/build_id_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,33 @@ def _check():
_check()
self.assertIn("ID: ab2e9f86b4109980930cdc685f4a320b359e7bb4", client.out)
self.assertNotIn("ID: f3989dcba0ab50dc5ed9b40ede202bdd7b421f09", client.out)

def failed_build_test(self):
conanfile = """from conans import ConanFile
class MyTest(ConanFile):
settings = "os"
def build(self):
raise Exception("Failed build!!")
"""
client = TestClient()
# NORMAL case, every create fails
client.save({"conanfile.py": conanfile})
error = client.run("create . pkg/0.1@user/channel", ignore_error=True)
self.assertTrue(error)
self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5",
client.out)
error = client.run("create . pkg/0.1@user/channel", ignore_error=True)
self.assertTrue(error)
self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5",
client.out)
# now test with build_id
client.save({"conanfile.py": conanfile +
" def build_id(self): self.info_build.settings.os = 'any'"})
error = client.run("create . pkg/0.1@user/channel", ignore_error=True)
self.assertTrue(error)
self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5",
client.out)
error = client.run("create . pkg/0.1@user/channel", ignore_error=True)
self.assertTrue(error)
self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5",
client.out)