Skip to content

Commit d28a5fc

Browse files
committed
test files
1 parent f5fdd8f commit d28a5fc

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

tmc-langs-util/src/task_executor/course_refresher.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ fn get_exercises(
312312
name,
313313
points,
314314
checksum,
315-
path: exercise_dir.to_path_buf(),
315+
path: exercise_dir,
316316
})
317317
})
318318
.collect::<Result<_, UtilError>>()?;
@@ -323,7 +323,10 @@ fn calculate_checksum(exercise_dir: &Path) -> Result<String, UtilError> {
323323
let mut digest = Context::new();
324324

325325
// order filenames for a consistent hash
326-
for entry in WalkDir::new(exercise_dir).sort_by(|a, b| a.file_name().cmp(b.file_name())) {
326+
for entry in WalkDir::new(exercise_dir)
327+
.min_depth(1) // do not hash the directory itself ('.')
328+
.sort_by(|a, b| a.file_name().cmp(b.file_name()))
329+
{
327330
let entry = entry?;
328331
let relative = entry.path().strip_prefix(exercise_dir).unwrap();
329332
let string = relative.as_os_str().to_string_lossy();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'pathname'
2+
require 'digest/md5'
3+
4+
def stub_files(path)
5+
sorted_list_of_files_under(path)
6+
end
7+
8+
9+
def sorted_list_of_files_under(dir)
10+
result = []
11+
base_path = Pathname(dir)
12+
Dir.chdir(base_path) do
13+
Pathname('.').find do |path|
14+
result << path unless path.to_s == '.'
15+
end
16+
end
17+
result.sort
18+
end
19+
20+
base_path = Pathname(ARGV[0])
21+
digest = Digest::MD5.new
22+
Dir.chdir(base_path) do
23+
stub_files(base_path).each do |path|
24+
puts "updating " + path.to_s
25+
digest.update(path.to_s)
26+
puts "updating with file" unless path.directory?
27+
digest.file(path.to_s) unless path.directory?
28+
puts ""
29+
end
30+
end
31+
checksum = digest.hexdigest
32+
puts checksum
33+

tmc-langs-util/tests/data/course_refresher/valid_exercises/ex1/.hidden file that should be included in the hash

Whitespace-only changes.

0 commit comments

Comments
 (0)