File: test_json.sh

package info (click to toggle)
debci 3.13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,656 kB
  • sloc: ruby: 6,516; sh: 2,437; javascript: 100; makefile: 92; perl: 11
file content (34 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

. $(dirname $0)/test_helper.sh

test_valid_json_after_one_single_run() {
  start_worker
  debci enqueue rake
  wait_for_results rake
  check_valid_json

}

check_valid_json() {
  ruby <<EOF || fail 'found invalid JSON files'
    require 'json'
    failed = 0
    json = Dir.glob(File.join('${debci_data_basedir}', '**/*.json'))
    if json.size == 0
      puts "Found no JSON files to check"
      exit(1)
    end
    json.each do |file|
      begin
        JSON.parse(File.read(file))
      rescue JSON::ParserError => exc
        puts "#{file} contains invalid JSON: #{exc.message}"
        failed += 1
      end
    end
    exit(failed)
EOF
}

. shunit2