testexecdir = join_paths(installed_test_bindir, 'css', 'parser')
testdatadir = join_paths(installed_test_datadir, 'css')

test_parser = executable('test-css-parser', 'test-css-parser.c',
                         install: get_option('install-tests'),
                         install_dir: testexecdir,
                         dependencies: libgtk_dep)

test_data = [
  'animation-crash-3.12.css',
  'animation-crash-3.12.errors',
  'animation-crash-3.12.ref.css',
  'animation-delay.css',
  'animation-delay.ref.css',
  'animation-direction.css',
  'animation-direction.ref.css',
  'animation-duration.css',
  'animation-duration.ref.css',
  'animation-fill-mode.css',
  'animation-fill-mode.ref.css',
  'animation-iteration-count.css',
  'animation-iteration-count.ref.css',
  'animation-name.css',
  'animation-name.ref.css',
  'animation-play-state.css',
  'animation-play-state.ref.css',
  'animation-shorthand-crash.css',
  'animation-shorthand-crash.ref.css',
  'animation-timing-function.css',
  'animation-timing-function.ref.css',
  'at-invalid-01.css',
  'at-invalid-01.errors',
  'at-invalid-01.ref.css',
  'at-invalid-02.css',
  'at-invalid-02.errors',
  'at-invalid-02.ref.css',
  'at-invalid-03.css',
  'at-invalid-03.errors',
  'at-invalid-03.ref.css',
  'at-invalid-04.css',
  'at-invalid-04.errors',
  'at-invalid-04.ref.css',
  'at-invalid-05.css',
  'at-invalid-05.errors',
  'at-invalid-05.ref.css',
  'at-invalid-06.css',
  'at-invalid-06.errors',
  'at-invalid-06.ref.css',
  'at-invalid-07.css',
  'at-invalid-07.errors',
  'at-invalid-07.ref.css',
  'at-invalid-08.css',
  'at-invalid-08.errors',
  'at-invalid-08.ref.css',
  'at-invalid-09.css',
  'at-invalid-09.errors',
  'at-invalid-09.ref.css',
  'at-invalid-10.css',
  'at-invalid-10.errors',
  'at-invalid-10.ref.css',
  'at-invalid-11.css',
  'at-invalid-11.errors',
  'at-invalid-11.ref.css',
  'at-invalid-12.css',
  'at-invalid-12.errors',
  'at-invalid-12.ref.css',
  'at-invalid-13.css',
  'at-invalid-13.errors',
  'at-invalid-13.ref.css',
  'at-invalid-14.css',
  'at-invalid-14.errors',
  'at-invalid-14.ref.css',
  'at-invalid-15.css',
  'at-invalid-15.errors',
  'at-invalid-15.ref.css',
  'at-invalid-16.css',
  'at-invalid-16.errors',
  'at-invalid-16.ref.css',
  'at-invalid-17.css',
  'at-invalid-17.errors',
  'at-invalid-17.ref.css',
  'at-invalid-18.css',
  'at-invalid-18.errors',
  'at-invalid-18.ref.css',
  'at-invalid-19.css',
  'at-invalid-19.errors',
  'at-invalid-19.ref.css',
  'at-invalid-20.css',
  'at-invalid-20.errors',
  'at-invalid-20.ref.css',
  'at-invalid-21.css',
  'at-invalid-21.errors',
  'at-invalid-21.ref.css',
  'at-invalid-22.css',
  'at-invalid-22.errors',
  'at-invalid-22.ref.css',
  'at-valid-01.css',
  'at-valid-01.ref.css',
  'at-valid-02.css',
  'at-valid-02.ref.css',
  'at-valid-03.css',
  'at-valid-03.ref.css',
  'at-valid-04.css',
  'at-valid-04.ref.css',
  'at-valid-05.css',
  'at-valid-05.ref.css',
  'at-valid-06.css',
  'at-valid-06.ref.css',
  'at-valid-07.css',
  'at-valid-08.css',
  'at-valid-08.ref.css',
  'at-valid-09.css',
  'at-valid-09.ref.css',
  'at-valid-10.css',
  'at-valid-10.ref.css',
  'at-valid-11.css',
  'at-valid-11.ref.css',
  'at-valid-12.css',
  'at-valid-12.ref.css',
  'at-valid-13.css',
  'at-valid-13.ref.css',
  'at-valid-14.css',
  'at-valid-14.ref.css',
  'at-valid-15.css',
  'at-valid-15.ref.css',
  'at-valid-16.css',
  'at-valid-16.ref.css',
  'at-valid-17.css',
  'at-valid-18.css',
  'at-valid-18.ref.css',
  'background-blend-mode.css',
  'background-blend-mode.ref.css',
  'background-clip.css',
  'background-clip.ref.css',
  'background-image.css',
  'background-image.ref.css',
  'background-origin.css',
  'background-origin.ref.css',
  'background-position.css',
  'background-position.errors',
  'background-position-errors.css',
  'background-position-errors.errors',
  'background-position-errors.ref.css',
  'background-position.ref.css',
  'background-repeat.css',
  'background-repeat.ref.css',
  'background-shorthand.css',
  'background-shorthand.ref.css',
  'background-shorthand-single.css',
  'background-shorthand-single.ref.css',
  'background-size.css',
  'background-size.ref.css',
  'backslash.css',
  'backslash.errors',
  'backslash.ref.css',
  'backslash-eof-is-identifier.css',
  'backslash-eof-is-identifier.errors',
  'backslash-eof-is-identifier.ref.css',
  'border-color.css',
  'border-color-currentcolor.css',
  'border-color-currentcolor.ref.css',
  'border-color.ref.css',
  'border.css',
  'border.errors',
  'border-image-repeat.css',
  'border-image-repeat.ref.css',
  'border-image-slice.css',
  'border-image-slice.ref.css',
  'border-image-source.css',
  'border-image-source.ref.css',
  'border-image-width.css',
  'border-image-width.ref.css',
  'border-infloop-3.12.css',
  'border-infloop-3.12.errors',
  'border-infloop-3.12.ref.css',
  'border-radius.css',
  'border-radius.ref.css',
  'border-radius-shorthand.css',
  'border-radius-shorthand.errors',
  'border-radius-shorthand.ref.css',
  'border.ref.css',
  'border-shorthand.css',
  'border-shorthand.ref.css',
  'border-spacing.css',
  'border-spacing.ref.css',
  'border-style.css',
  'border-style.ref.css',
  'border-width.css',
  'border-width.ref.css',
  'box-shadow.css',
  'box-shadow.ref.css',
  'calc.css',
  'calc-errors.css',
  'calc-errors.errors',
  'calc-errors.ref.css',
  'calc.ref.css',
  'calc-simple.css',
  'calc-simple.ref.css',
  'close-at-end-of-file.css',
  'close-at-end-of-file.errors',
  'close-at-end-of-file.ref.css',
  'color.css',
  'color.ref.css',
  'colors-errors.css',
  'colors-errors.errors',
  'colors-errors.ref.css',
  'colors-red.css',
  'colors-red.ref.css',
  'comment-detection.css',
  'comment-detection.ref.css',
  'cross-fade-basic.css',
  'css-21-malformed-declarations.css',
  'css-21-malformed-declarations.errors',
  'css-21-malformed-declarations.ref.css',
  'css-21-malformed-statements.css',
  'css-21-malformed-statements.errors',
  'css-21-malformed-statements.ref.css',
  'currentcolor-everywhere.css',
  'dash-backslash-eof-is-identifier.ref.css',
  'dash-backslash-eof-is-identifier.css',
  'dash-backslash-eof-is-identifier.errors',
  'dash-backslash-newline-is-delim.ref.css',
  'dash-backslash-newline-is-delim.errors',
  'dash-backslash-newline-is-delim.css',
  'dash-dash-eof-is-identifier.ref.css',
  'dash-dash-eof-is-identifier.css',
  'dash-dash-eof-is-identifier.errors',
  'dash-eof-is-delim.ref.css',
  'dash-eof-is-delim.css',
  'dash-eof-is-delim.errors',
  'declarations.css',
  'declarations.errors',
  'declarations-invalid-01.css',
  'declarations-invalid-01.errors',
  'declarations-invalid-01.ref.css',
  'declarations-invalid-02.css',
  'declarations-invalid-02.errors',
  'declarations-invalid-02.ref.css',
  'declarations-invalid-03.css',
  'declarations-invalid-03.errors',
  'declarations-invalid-03.ref.css',
  'declarations-invalid-04.css',
  'declarations-invalid-04.errors',
  'declarations-invalid-04.ref.css',
  'declarations-invalid-05.css',
  'declarations-invalid-05.errors',
  'declarations-invalid-05.ref.css',
  'declarations-invalid-06.css',
  'declarations-invalid-06.errors',
  'declarations-invalid-06.ref.css',
  'declarations-invalid-07.css',
  'declarations-invalid-07.errors',
  'declarations-invalid-07.ref.css',
  'declarations-invalid-08.css',
  'declarations-invalid-08.errors',
  'declarations-invalid-08.ref.css',
  'declarations.ref.css',
  'declarations-valid-01.css',
  'declarations-valid-01.ref.css',
  'declarations-valid-02.css',
  'declarations-valid-02.errors',
  'declarations-valid-02.ref.css',
  'declarations-valid-03.css',
  'declarations-valid-03.ref.css',
  'declarations-valid-04.css',
  'declarations-valid-04.ref.css',
  'declarations-valid-05.css',
  'declarations-valid-05.ref.css',
  'declarations-valid-06.css',
  'declarations-valid-06.ref.css',
  'declarations-valid-07.css',
  'declarations-valid-07.ref.css',
  'declarations-valid-08.css',
  'declarations-valid-08.ref.css',
  'declarations-valid-09.css',
  'declarations-valid-09.ref.css',
  'declarations-valid-10.css',
  'declarations-valid-10.ref.css',
  'declarations-valid-11.css',
  'declarations-valid-11.ref.css',
  'declarations-valid-12.css',
  'declarations-valid-12.ref.css',
  'declarations-valid-13.css',
  'declarations-valid-13.ref.css',
  'declarations-valid-14.css',
  'declarations-valid-14.ref.css',
  'declarations-valid-15.css',
  'declarations-valid-15.ref.css',
  'declarations-valid-16.css',
  'declarations-valid-16.ref.css',
  'declarations-valid-17.css',
  'declarations-valid-17.ref.css',
  'declarations-valid-18.css',
  'declarations-valid-18.ref.css',
  'declarations-valid-22.css',
  'declarations-valid-22.ref.css',
  'declarations-valid-23.css',
  'declarations-valid-23.ref.css',
  'declarations-valid-24.css',
  'declarations-valid-24.ref.css',
  'declarations-valid-25.css',
  'declarations-valid-25.ref.css',
  'declarations-valid-26.css',
  'declarations-valid-26.ref.css',
  'does-not-exist.css',
  'does-not-exist.errors',
  'does-not-exist.ref.css',
  'doubled.css',
  'doubled.ref.css',
  'empty.css',
  'font-family.css',
  'font-family.ref.css',
  'font-size.css',
  'font-size.ref.css',
  'font-stretch.css',
  'font-stretch.ref.css',
  'font-style.css',
  'font-style.ref.css',
  'font-variant.css',
  'font-variant.ref.css',
  'font-weight.css',
  'font-weight.ref.css',
  'freed-string-in-error-messages.css',
  'freed-string-in-error-messages.errors',
  'freed-string-in-error-messages.ref.css',
  'import-cyclic-1.css',
  'import-cyclic-1.errors',
  'import-cyclic-1.ref.css',
  'import-cyclic-2.css',
  'import-cyclic-2.errors',
  'import-cyclic-2.ref.css',
  'import-cyclic-3.css',
  'import-cyclic-3.errors',
  'import-cyclic-3.ref.css',
  'import-nonexistant.css',
  'import-nonexistant.errors',
  'import-nonexistant.ref.css',
  'import-recursive.css',
  'import-recursive.errors',
  'import-recursive.ref.css',
  'integer.css',
  'integer.errors',
  'integer.ref.css',
  'keyframes-empty.css',
  'keyframes-empty.ref.css',
  'keyframes-ordering.css',
  'keyframes-ordering.ref.css',
  'letter-spacing.css',
  'letter-spacing.ref.css',
  'linear-gradient.css',
  'linear-gradient.ref.css',
  'margin.css',
  'margin.ref.css',
  'min-height.css',
  'min-height.ref.css',
  'min-width.css',
  'min-width.ref.css',
  'newline-after-backslash.css',
  'newline-after-backslash.errors',
  'newline-after-backslash.ref.css',
  'newline-after-backslash-original.css',
  'newline-after-backslash-original.errors',
  'newline-after-backslash-original.ref.css',
  'no-semicolon.css',
  'no-semicolon.errors',
  'no-semicolon.ref.css',
  'not.css',
  'not.ref.css',
  'nth-child.css',
  'nth-child.ref.css',
  'opacity.css',
  'opacity.ref.css',
  'outline-color.css',
  'outline-color.ref.css',
  'outline-offset.css',
  'outline-offset.ref.css',
  'outline-radius.css',
  'outline-radius.ref.css',
  'outline-style.css',
  'outline-style.ref.css',
  'outline-width.css',
  'outline-width.ref.css',
  'padding.css',
  'padding.ref.css',
  'property-name-errors.css',
  'property-name-errors.errors',
  'property-name-errors.ref.css',
  'pseudo-classes-known.css',
  'pseudo-classes-known.ref.css',
  'pseudo-classes-unknown.css',
  'pseudo-classes-unknown.errors',
  'pseudo-classes-unknown.ref.css',
  'radial-background-position-error.css',
  'radial-background-position-error.errors',
  'radial-background-position-error.ref.css',
  'radial.css',
  'radial-positions.css',
  'radial-positions.errors',
  'radial-positions.ref.css',
  'radial.ref.css',
  'selector.css',
  'selector.ref.css',
  'shadow.css',
  'shadow.ref.css',
  'shadow-ordering.css',
  'shadow-ordering.ref.css',
  'shorthand.css',
  'shorthand.ref.css',
  'simple.css',
  'single-slash.css',
  'single-slash.errors',
  'single-slash.ref.css',
  'string-values.css',
  'string-values.ref.css',
  'test.png',
  'text-decoration-color.css',
  'text-decoration-color.ref.css',
  'text-decoration-line.css',
  'text-decoration-line.ref.css',
  'text-decoration-style.css',
  'text-decoration-style.ref.css',
  'text-shadow.css',
  'text-shadow-invalid-but-worked-in-3.12.css',
  'text-shadow-invalid-but-worked-in-3.12.errors',
  'text-shadow-invalid-but-worked-in-3.12.ref.css',
  'text-shadow.ref.css',
  'transition.css',
  'transition-delay.css',
  'transition-delay.ref.css',
  'transition-duration.css',
  'transition-duration.ref.css',
  'transition-property.css',
  'transition-property.ref.css',
  'transition.ref.css',
  'transition-timing-function.css',
  'transition-timing-function.ref.css',
  'value-inherit.css',
  'value-inherit.ref.css',
  'value-inherit.errors',
  'value-inherit-shorthand.css',
  'value-inherit-shorthand.ref.css',
  'value-initial.css',
  'value-initial.ref.css',
  'value-initial.errors',
  'value-initial-shorthand.css',
  'value-initial-shorthand.ref.css',
  'value-none.css',
  'value-none.errors',
  'value-none.ref.css',
]

foreach testname : test_data
  if testname.endswith('.css') and not testname.endswith('.ref.css')
    test('parser ' + testname, test_parser,
         args: [ '--tap',
                 '-k',
                 join_paths(meson.current_source_dir(), testname),
               ],
         env: [ 'GIO_USE_VOLUME_MONITOR=unix',
                'GSETTINGS_BACKEND=memory',
                'GTK_CSD=1',
                'G_ENABLE_DIAGNOSTIC=0',
                'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
                 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
              ],
         suite: 'css')
  endif
endforeach

if get_option('install-tests')
  conf = configuration_data()
  conf.set('libexecdir', gtk_libexecdir)
  configure_file(input: 'parser.test.in',
                 output: 'parser.test',
                 configuration: conf,
                 install_dir: testdatadir)

  install_data(test_data, install_dir: testexecdir)

endif
