Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
8060ad8c
Commit
8060ad8c
authored
6 years ago
by
Jürg Billeter
Browse files
Options
Downloads
Patches
Plain Diff
tests/sources/git.py: Add track and fetch test with and without tag
parent
107269c1
No related branches found
No related tags found
1 merge request
!291
git.py: Make `ref` human readable
Pipeline
#31377020
passed
6 years ago
Stage: prepare
Stage: test
Stage: post
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/sources/git.py
+47
-0
47 additions, 0 deletions
tests/sources/git.py
with
47 additions
and
0 deletions
tests/sources/git.py
+
47
−
0
View file @
8060ad8c
...
...
@@ -476,3 +476,50 @@ def test_ref_not_in_track_warn_error(cli, tmpdir, datafiles):
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
build
'
,
'
target.bst
'
])
result
.
assert_main_error
(
ErrorDomain
.
STREAM
,
None
)
result
.
assert_task_error
(
ErrorDomain
.
PLUGIN
,
CoreWarnings
.
REF_NOT_IN_TRACK
)
@pytest.mark.skipif
(
HAVE_GIT
is
False
,
reason
=
"
git is not available
"
)
@pytest.mark.datafiles
(
os
.
path
.
join
(
DATA_DIR
,
'
template
'
))
@pytest.mark.parametrize
(
"
ref_format
"
,
[
'
sha1
'
,
'
git-describe
'
])
@pytest.mark.parametrize
(
"
tag,extra_commit
"
,
[(
False
,
False
),
(
True
,
False
),
(
True
,
True
)])
def
test_track_fetch
(
cli
,
tmpdir
,
datafiles
,
ref_format
,
tag
,
extra_commit
):
project
=
os
.
path
.
join
(
datafiles
.
dirname
,
datafiles
.
basename
)
# Create the repo from 'repofiles' subdir
repo
=
create_repo
(
'
git
'
,
str
(
tmpdir
))
ref
=
repo
.
create
(
os
.
path
.
join
(
project
,
'
repofiles
'
))
if
tag
:
repo
.
add_tag
(
'
tag
'
)
if
extra_commit
:
repo
.
add_commit
()
# Write out our test target
element
=
{
'
kind
'
:
'
import
'
,
'
sources
'
:
[
repo
.
source_config
()
]
}
element
[
'
sources
'
][
0
][
'
ref-format
'
]
=
ref_format
element_path
=
os
.
path
.
join
(
project
,
'
target.bst
'
)
_yaml
.
dump
(
element
,
element_path
)
# Track it
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
track
'
,
'
target.bst
'
])
result
.
assert_success
()
element
=
_yaml
.
load
(
element_path
)
new_ref
=
element
[
'
sources
'
][
0
][
'
ref
'
]
if
ref_format
==
'
git-describe
'
and
tag
:
# Check and strip prefix
prefix
=
'
tag-{}-g
'
.
format
(
0
if
not
extra_commit
else
1
)
assert
new_ref
.
startswith
(
prefix
)
new_ref
=
new_ref
[
len
(
prefix
):]
# 40 chars for SHA-1
assert
len
(
new_ref
)
==
40
# Fetch it
result
=
cli
.
run
(
project
=
project
,
args
=
[
'
fetch
'
,
'
target.bst
'
])
result
.
assert_success
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment