Skip to content

Instantly share code, notes, and snippets.

@paul-hammant
Created September 13, 2017 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paul-hammant/058161485a227299e5d7c34cc6a33264 to your computer and use it in GitHub Desktop.
Save paul-hammant/058161485a227299e5d7c34cc6a33264 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# svnviewspec_tests.py: testing the 'svn-viewspec.py' tool.
#
# Subversion is a tool for revision control.
# See http://subversion.apache.org for more information.
#
# ====================================================================
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
######################################################################
import sys
import os.path
import tempfile
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
sys.path.append(
os.path.abspath(root_dir + "/tools/client-side/"))
svn_viewspec = __import__("svn-viewspec")
os_system_lines = []
def my_os_system(str):
os_system_lines.append(str)
def test_that_viewspec_does_the_right_thing_for_its_own_inline_example():
spec = """Format: 1
Url: http://svn.apache.org/repos/asf/subversion
Revision: 36366
trunk/**
branches/1.5.x/**
branches/1.6.x/**
README
branches/1.4.x/STATUS
branches/1.4.x/subversion/tests/cmdline/~
"""
new_file, filename = tempfile.mkstemp()
os.write(new_file, spec)
os.close(new_file)
svn_viewspec.perform_viewspec(my_os_system, ["checkout", "checkout", filename, "foo/bar"])
expected = \
"""svn checkout "http://svn.apache.org/repos/asf/subversion" "foo/bar" --depth=empty --revision=36366
svn update "foo/bar/README" --set-depth=empty --revision=36366
svn update "foo/bar/branches" --set-depth=empty --revision=36366
svn update "foo/bar/branches/1.4.x" --set-depth=empty --revision=36366
svn update "foo/bar/branches/1.4.x/STATUS" --set-depth=empty --revision=36366
svn update "foo/bar/branches/1.4.x/subversion" --set-depth=empty --revision=36366
svn update "foo/bar/branches/1.4.x/subversion/tests" --set-depth=empty --revision=36366
svn update "foo/bar/branches/1.4.x/subversion/tests/cmdline" --set-depth=files --revision=36366
svn update "foo/bar/branches/1.5.x" --set-depth=infinity --revision=36366
svn update "foo/bar/branches/1.6.x" --set-depth=infinity --revision=36366
svn update "foo/bar/trunk" --set-depth=infinity --revision=36366 """.splitlines()
for i, line in enumerate(os_system_lines):
assert line.strip() == expected[i].strip()
assert len(os_system_lines) == len(expected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment