-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #681 from Xarthisius/abspath_in_scripts
[MRG] Allow absolute paths in build_script_files. Fixes #673
- Loading branch information
Showing
2 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Test if assemble scripts from outside of r2d repo are accepted.""" | ||
import time | ||
from repo2docker.app import Repo2Docker | ||
from repo2docker.buildpacks import PythonBuildPack | ||
|
||
|
||
def test_Repo2Docker_external_build_scripts(tmpdir): | ||
tempfile = tmpdir.join("absolute-script") | ||
tempfile.write("Hello World of Absolute Paths!") | ||
|
||
class MockBuildPack(PythonBuildPack): | ||
def detect(self): | ||
return True | ||
|
||
def get_build_script_files(self): | ||
files = {str(tempfile): "/tmp/my_extra_script"} | ||
files.update(super().get_build_script_files()) | ||
return files | ||
|
||
app = Repo2Docker(repo=str(tmpdir)) | ||
app.buildpacks = [MockBuildPack] | ||
app.initialize() | ||
app.build() | ||
container = app.start_container() | ||
|
||
# give the container a chance to start | ||
tic = 180 | ||
while container.status != "running" or tic < 0: | ||
time.sleep(1) | ||
tic -= 1 | ||
|
||
assert container.status == "running" | ||
|
||
try: | ||
status, output = container.exec_run(["sh", "-c", "cat /tmp/my_extra_script"]) | ||
assert status == 0 | ||
assert output.decode("utf-8") == "Hello World of Absolute Paths!" | ||
finally: | ||
container.stop(timeout=1) | ||
container.reload() | ||
assert container.status == "exited", container.status | ||
container.remove() |