@@ -10,6 +10,7 @@ import { tmpdir } from "node:os"
10
10
import {
11
11
getJuliaCompatRange ,
12
12
getJuliaProjectFile ,
13
+ getJuliaManifestFile ,
13
14
validJuliaCompatRange ,
14
15
} from "../src/project.js"
15
16
@@ -26,10 +27,10 @@ describe("getJuliaProjectFile tests", () => {
26
27
27
28
it ( "Can determine project file is missing" , ( ) => {
28
29
expect ( ( ) => getJuliaProjectFile ( "DNE.toml" ) ) . toThrow (
29
- "Unable to locate project file"
30
+ "Unable to locate Julia project file"
30
31
)
31
32
expect ( ( ) => getJuliaProjectFile ( "." ) ) . toThrow (
32
- "Unable to locate project file"
33
+ "Unable to locate Julia project file"
33
34
)
34
35
} )
35
36
@@ -70,6 +71,60 @@ describe("getJuliaProjectFile tests", () => {
70
71
} )
71
72
} )
72
73
74
+ describe ( "getJuliaManifestFile tests" , ( ) => {
75
+ let orgWorkingDir : string
76
+
77
+ beforeEach ( ( ) => {
78
+ orgWorkingDir = process . cwd ( )
79
+ } )
80
+
81
+ afterEach ( ( ) => {
82
+ process . chdir ( orgWorkingDir )
83
+ } )
84
+
85
+ it ( "Can determine manifest file is missing" , ( ) => {
86
+ expect ( ( ) => getJuliaManifestFile ( "." ) ) . toThrow (
87
+ "Unable to locate Julia manifest file"
88
+ )
89
+ } )
90
+
91
+ it ( "Can determine project file from a directory" , ( ) => {
92
+ fs . mkdtemp ( path . join ( tmpdir ( ) , "julia-version-" ) , ( err , projectDir ) => {
93
+ const manifestFile = path . join ( projectDir , "Manifest.toml" )
94
+ fs . closeSync ( fs . openSync ( manifestFile , "w" ) )
95
+ expect ( getJuliaManifestFile ( projectDir ) ) . toEqual ( manifestFile )
96
+ } )
97
+
98
+ fs . mkdtemp ( path . join ( tmpdir ( ) , "julia-version-" ) , ( err , projectDir ) => {
99
+ const manifestFile = path . join ( projectDir , "JuliaManifest.toml" )
100
+ fs . closeSync ( fs . openSync ( manifestFile , "w" ) )
101
+ expect ( getJuliaManifestFile ( projectDir ) ) . toEqual ( manifestFile )
102
+ } )
103
+ } )
104
+
105
+ it ( "Prefers using JuliaManifest.toml over Manifest.toml" , ( ) => {
106
+ fs . mkdtemp ( path . join ( tmpdir ( ) , "julia-version-" ) , ( err , projectDir ) => {
107
+ const manifestFile = path . join ( projectDir , "Manifest.toml" )
108
+ fs . closeSync ( fs . openSync ( manifestFile , "w" ) )
109
+
110
+ const juliaManifestFile = path . join ( projectDir , "JuliaManifest.toml" )
111
+ fs . closeSync ( fs . openSync ( juliaManifestFile , "w" ) )
112
+
113
+ expect ( getJuliaManifestFile ( projectDir ) ) . toEqual ( juliaManifestFile )
114
+ } )
115
+ } )
116
+
117
+ it ( "Can determine project from the current working directory" , ( ) => {
118
+ fs . mkdtemp ( path . join ( tmpdir ( ) , "julia-version-" ) , ( err , projectDir ) => {
119
+ const projectFile = path . join ( projectDir , "Manifest.toml" )
120
+ fs . closeSync ( fs . openSync ( projectFile , "w" ) )
121
+
122
+ process . chdir ( projectDir )
123
+ expect ( getJuliaManifestFile ( "." ) ) . toEqual ( "Manifest.toml" )
124
+ } )
125
+ } )
126
+ } )
127
+
73
128
describe ( "validJuliaCompatRange tests" , ( ) => {
74
129
it ( "Handles default caret specifier" , ( ) => {
75
130
expect ( validJuliaCompatRange ( "1" ) ) . toEqual ( semver . validRange ( "^1" ) )
0 commit comments