File: test_json.sh

package info (click to toggle)
debci 0.10.3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 904 kB
  • ctags: 310
  • sloc: sh: 1,662; ruby: 1,007; makefile: 35
file content (23 lines) | stat: -rwxr-xr-x 456 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

. $(dirname $0)/test_helper.sh

test_valid_json() {
  debci batch

  ruby <<EOF || fail 'found invalid JSON files'
    require 'json'
    failed = 0
    Dir.glob(File.join('${debci_data_basedir}', '**/*.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