~ubuntu-branches/ubuntu/quantal/ruby-ferret/quantal

« back to all changes in this revision

Viewing changes to test/unit/store/tc_fs_store.rb

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2012-06-14 23:04:48 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20120614230448-wd5se4ia1yz7dvms
Tags: 0.11.8.4+debian-1
* New upstream version from a new source
  + the new code fixes format security issues (Closes: #672069)
  + change homepage to https://github.com/jkraemer/ferret/
* Build for all Ruby versions (Closes: #655636)
  + change depends accordingly
  + do not set shebang of bin/ferret to ruby1.8
* Repack source to remove convenience copy of bzlib
  + build-dep on libbz2-dev
  + dversionmangle in debian/watch
  + add debian/README.source explaining how to clean the source
* debian/patches:
  + disable_load_path_manipulation.patch: do not override $LOAD_PATH
  + disable_test_causing_segfault.patch: temporarily disable a test known to
    cause segfaults
  + fix_compatibility_with_minitest.patch: fix a failing test with Ruby1.9
  + use_system_bzlib.patch: adapt the source to use system libbz2
  + fix_typos_in_source_code.patch: correct some spelling errors in the
    source code
  + block_variables_have_local_scopes.patch: fix syntax in
    bin/ferret-browser
* Override dh_auto_clean to remove test/temp when cleaning
* Bump Standards-Version to 3.9.3 (no changes needed)
* Set priority of transitional packages to extra
* Add myself to Uploaders:
* Update copyright to DEP-5 copyright-format/1.0
* Add TUTORIAL and debian/README.source to documents
* Override lintian warnings about duplicate descriptions of transitional
  packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
require File.dirname(__FILE__) + "/tm_store"
3
3
require File.dirname(__FILE__) + "/tm_store_lock"
4
4
 
 
5
require 'fileutils'
 
6
 
5
7
class FSStoreTest < Test::Unit::TestCase
6
8
  include Ferret::Store
7
9
  include StoreTest
13
15
  end
14
16
 
15
17
  def teardown
16
 
    @dir.refresh()
17
18
    @dir.close()
 
19
    Dir[File.join(@dpath, "*")].each {|path| begin File.delete(path) rescue nil end}
18
20
  end
19
21
 
20
22
  def test_fslock
21
 
    lock_name = "lfile"
 
23
    lock_name = "_file.f1"
22
24
    lock_file_path = make_lock_file_path(lock_name)
23
25
    assert(! File.exists?(lock_file_path), "There should be no lock file")
24
26
    lock = @dir.make_lock(lock_name)
63
65
#    assert(! File.exists?(lock_file_path), "The lock file should have been deleted")
64
66
#  end
65
67
#
 
68
  def test_permissions
 
69
    _S_IRGRP = 0040
 
70
    _S_IWGRP = 0020
 
71
 
 
72
    dpath = File.expand_path(File.join(File.dirname(__FILE__),
 
73
                       '../../temp/fsdir_permissions'))
 
74
 
 
75
    FileUtils.mkdir_p(dpath)
 
76
    dstat = File.stat(dpath)
 
77
 
 
78
    File.chown(nil, `id -G`.split.last.to_i, dpath)
 
79
    File.chmod(dstat.mode | _S_IRGRP | _S_IWGRP, dpath)
 
80
 
 
81
    dir = FSDirectory.new(dpath, true)
 
82
 
 
83
    file_name = 'test_permissions'
 
84
    file_path = File.join(dpath, file_name)
 
85
 
 
86
    dir.touch(file_name)
 
87
 
 
88
    mode = File.stat(file_path).mode
 
89
 
 
90
    assert(mode & _S_IRGRP == _S_IRGRP, "file should be group-readable")
 
91
    assert(mode & _S_IWGRP == _S_IWGRP, "file should be group-writable")
 
92
  ensure
 
93
    if dstat
 
94
      File.chown(nil, dstat.gid, dpath)
 
95
      File.chmod(dstat.mode, dpath)
 
96
    end
 
97
 
 
98
    if dir
 
99
      dir.refresh()
 
100
      dir.close()
 
101
    end
 
102
  end
 
103
 
66
104
  def make_lock_file_path(name)
67
105
    lock_file_path = File.join(@dpath, lfname(name))
68
106
    if File.exists?(lock_file_path) then