25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.0KB

  1. require 'test/unit'
  2. module Mustache
  3. extend self
  4. ROOT = File.expand_path('../..', __FILE__)
  5. TEST = File.join(ROOT, 'test')
  6. TEST_FILES = File.join(TEST, '_files')
  7. MUSTACHE_JS = File.read(File.join(ROOT, 'mustache.js'))
  8. TESTS = Dir.glob(File.join(TEST_FILES, '*.js')).map do |name|
  9. File.basename name, '.js'
  10. end
  11. NODE_PATH = `which node`.strip
  12. JS_PATH = `which js`.strip
  13. JSC_PATH = "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"
  14. RHINO_JAR = "org.mozilla.javascript.tools.shell.Main"
  15. def javascript_engines
  16. %w[v8 spidermonkey javascriptcore rhino]
  17. end
  18. def available_javascript_engines
  19. javascript_engines.select {|engine| send("has_#{engine}?") }
  20. end
  21. def has_any_engines?
  22. available_javascript_engines.any?
  23. end
  24. def has_v8?
  25. File.exist?(NODE_PATH)
  26. end
  27. def has_spidermonkey?
  28. File.exist?(JS_PATH)
  29. end
  30. def has_javascriptcore?
  31. File.exist?(JSC_PATH)
  32. end
  33. def has_rhino?
  34. `java #{RHINO_JAR} 'foo' 2>&1` !~ /ClassNotFoundException/
  35. end
  36. end