-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into test_api_build_dll_…
…package
- Loading branch information
Showing
7 changed files
with
73 additions
and
93 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
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 |
---|---|---|
@@ -1,24 +1,18 @@ | ||
# Copyright (C) 2014 Anaconda, Inc | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
import os | ||
import pytest | ||
|
||
from conda_build import api | ||
from conda_build.api import build | ||
|
||
from .utils import thisdir | ||
|
||
|
||
@pytest.fixture() | ||
def recipe(): | ||
return os.path.join(thisdir, 'test-recipes', 'go-package') | ||
from .utils import go_dir | ||
|
||
|
||
@pytest.mark.sanity | ||
@pytest.mark.serial | ||
def test_recipe_build(recipe, testing_config, testing_workdir, monkeypatch): | ||
def test_recipe_build(testing_config, testing_workdir, monkeypatch): | ||
# These variables are defined solely for testing purposes, | ||
# so they can be checked within build scripts | ||
testing_config.activate = True | ||
monkeypatch.setenv("CONDA_TEST_VAR", "conda_test") | ||
monkeypatch.setenv("CONDA_TEST_VAR_2", "conda_test_2") | ||
api.build(recipe, config=testing_config) | ||
build(go_dir, config=testing_config) |
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 |
---|---|---|
@@ -1,57 +1,42 @@ | ||
# Copyright (C) 2014 Anaconda, Inc | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
import sys | ||
import os | ||
import os.path | ||
from pathlib import Path | ||
|
||
from conda.common.compat import on_win | ||
from conda_build.os_utils.external import find_executable | ||
|
||
|
||
def test_find_executable(testing_workdir, monkeypatch): | ||
if sys.platform != "win32": | ||
import stat | ||
|
||
path_components = [] | ||
|
||
def create_file(unix_path, put_on_path, executable): | ||
localized_path = os.path.join(testing_workdir, *unix_path.split('/')) | ||
# empty prefix by default - extra bit at beginning of file | ||
if sys.platform == "win32": | ||
localized_path = localized_path + ".bat" | ||
|
||
dirname = os.path.split(localized_path)[0] | ||
if not os.path.isdir(dirname): | ||
os.makedirs(dirname) | ||
|
||
if sys.platform == "win32": | ||
prefix = "@echo off\n" | ||
else: | ||
prefix = "#!/bin/bash\nexec 1>&2\n" | ||
with open(localized_path, 'w') as f: | ||
f.write(prefix + """ | ||
echo ******* You have reached the dummy {}. It is likely there is a bug in | ||
echo ******* conda that makes it not add the _build/bin directory onto the | ||
echo ******* PATH before running the source checkout tool | ||
exit -1 | ||
""".format(localized_path)) | ||
|
||
if put_on_path: | ||
path_components.append(dirname) | ||
|
||
if executable: | ||
st = os.stat(localized_path) | ||
os.chmod(localized_path, st.st_mode | stat.S_IEXEC) | ||
|
||
return localized_path | ||
|
||
create_file('executable/not/on/path/with/target_name', put_on_path=False, executable=True) | ||
create_file('non_executable/on/path/with/target_name', put_on_path=True, executable=False) | ||
create_file('executable/on/path/with/non_target_name', put_on_path=True, executable=True) | ||
target_path = create_file('executable/on/path/with/target_name', put_on_path=True, executable=True) | ||
create_file('another/executable/later/on/path/with/target_name', put_on_path=True, executable=True) | ||
|
||
monkeypatch.setenv('PATH', os.pathsep.join(path_components)) | ||
|
||
find = find_executable('target_name') | ||
|
||
assert find == target_path, f"Expected to find 'target_name' in '{target_path}', but found it in '{find}'" | ||
search_path = [] | ||
|
||
def touch(target, searchable=True, executable=True, alternative=False): | ||
path = Path( | ||
testing_workdir, | ||
"alt" if alternative else "not", | ||
"exec" if executable else "not", | ||
"search" if searchable else "not", | ||
target, | ||
) | ||
if on_win: | ||
path = path.with_suffix(".bat") | ||
path.parent.mkdir(parents=True, exist_ok=True) | ||
|
||
path.touch(0o100 if executable else 0o666) | ||
|
||
if searchable: | ||
search_path.append(str(path.parent)) | ||
|
||
return str(path) | ||
|
||
touch("target", searchable=False) | ||
# Windows doesn't have an execute bit so this is the path found | ||
win_expected = touch("target", executable=False) | ||
touch("not_target") | ||
nix_expected = touch("target") | ||
touch("target", alternative=True) | ||
expected = win_expected if on_win else nix_expected | ||
|
||
monkeypatch.setenv("PATH", os.pathsep.join(search_path)) | ||
|
||
assert find_executable("target") == expected |
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