@@ -3,6 +3,7 @@ package qjs_test
33import (
44 "context"
55 "fmt"
6+ "os"
67 "sync"
78 "testing"
89 "time"
@@ -257,18 +258,23 @@ func TestRuntime(t *testing.T) {
257258 })
258259
259260 t .Run ("CacheDirOption" , func (t * testing.T ) {
260- rt1 , err := qjs .New (qjs.Option {CacheDir : t .TempDir ()})
261+ cacheDir := t .TempDir ()
262+ rt1 , err := qjs .New (qjs.Option {CacheDir : cacheDir , DisableBuildCache : true })
261263 require .NoError (t , err )
262- defer rt1 .Close ()
263264
264265 val , err := rt1 .Eval ("test.js" , qjs .Code ("21 + 21" ))
265266 require .NoError (t , err )
266267 assert .Equal (t , int32 (42 ), val .Int32 ())
267268 val .Free ()
269+
270+ rt1 .Close ()
271+ entries , err := os .ReadDir (cacheDir )
272+ require .NoError (t , err )
273+ assert .NotEmpty (t , entries , "Cache directory should not be empty" )
268274 })
269275
270276 t .Run ("CacheDirWithEmptyString" , func (t * testing.T ) {
271- rt , err := qjs .New (qjs.Option {CacheDir : "" })
277+ rt , err := qjs .New (qjs.Option {CacheDir : "" , DisableBuildCache : true })
272278 require .NoError (t , err )
273279 defer rt .Close ()
274280
@@ -279,7 +285,7 @@ func TestRuntime(t *testing.T) {
279285 })
280286
281287 t .Run ("CacheDirWithInvalidPath" , func (t * testing.T ) {
282- _ , err := qjs .New (qjs.Option {CacheDir : "/invalid/path/that/does/not/exist" , QuickJSWasmBytes : [] byte ( "cachedir" ) })
288+ _ , err := qjs .New (qjs.Option {CacheDir : "/invalid/path/that/does/not/exist" , DisableBuildCache : true })
283289 require .Error (t , err )
284290 assert .Contains (t , err .Error (), "failed to create compilation cache" )
285291 })
0 commit comments